Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace FST #1033

Open
simonpoole opened this issue Nov 5, 2019 · 5 comments
Open

Replace FST #1033

simonpoole opened this issue Nov 5, 2019 · 5 comments
Labels

Comments

@simonpoole
Copy link
Collaborator

See

and

RuedigerMoeller/fast-serialization#288

As FST seems to be deader than dead just 1 year after we switched to it, we need to replace it. Since this is key functionality for the app, it seems to be unwise to rely on any third party and we should simply role our own for at least the key objects that we need to save and restore.

@simonpoole simonpoole pinned this issue Nov 5, 2019
@simonpoole simonpoole added the Task label Nov 5, 2019
@simonpoole simonpoole added this to the 15.0 milestone Nov 17, 2019
@simonpoole simonpoole removed this from the 15.0 milestone Jun 6, 2020
@simonpoole
Copy link
Collaborator Author

FST has shown some life (though the Android issues are not fixed), so maybe we can delay this a bit.

@westnordost
Copy link

westnordost commented Oct 19, 2020

FYI I use https://github.com/EsotericSoftware/kryo (binary serialization) for StreetComplete, it's maintained, uses reflection to serialize the members. Using this https://github.com/westnordost/StreetComplete/blob/master/app/src/main/java/de/westnordost/streetcomplete/util/KryoSerializer.java for configuration, I can call

Date myDate = new Date();
byte[] dateBytes = serializer.toBytes(myDate);
Date thatSameDate = serializer.toObject(dateBytes, Date.class);
assertEquals(myDate, thatSameDate);

The only thing you'd have to look out for are that you never delete any of the registered classes, even changing the order of the members declaration of the registered classes will be a problem, as with probably any serialization to binary. I once had problems with serialization because Proguard tossed out an unused member variable from one of these classes, which resulted in that the serializer would de-serialize those that have been serialized before Proguard tossed out the unused member variable wrongly.

For this source of error, if I could go back in time, I would have chosen JSON serialization (with GSON or Moshi) over binary because what are a few bytes saved over such a problematic and non-obvious source of error?

@simonpoole
Copy link
Collaborator Author

@westnordost the alternative alternative is simply to serialize manually, I've just simply been a bit adverse to doing the, lot of, work involved.

@Doomsdayrs
Copy link

How about Kotlin serialization?

@westnordost
Copy link

FYI StreetComplete uses Kotlin Serialization (to/from JSON) now. I chose serialization to/from JSON because it is easy to switch out the implementation if the particular library one is using should not be used anymore for whatever reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants