> The only difference is that in the second case, mistakenly, the
> operation was done in the main thread. Do you think this can be the
> source of the problem? If so, why only on some Android 10 devices?
Multithreading is a common source of "sometimes we have a problem". If
you have a race condition that's "very unlikely to happen" (say, once in
a thousand cases), then if you have 1000 users, it is almost certain
that somebody will hit the problem, while your chances of reproducing
the problem are pretty slim.
You need to have some 150% enforced policy in the software that prevents
race conditions. It doesn't matter whether it is enforced through type
system, annotations, programmer discipline, testing, or whatever - but
it needs to be iron-clad and so reliable that you'd trust your family's
life with it.
Without that, you're in for misery for the rest of the app's lifetime.
General rules:
1) Avoid locking. Locks tend to deadlock, which is a nonlocal bug
(potentially far-away parts of the code can contribute to deadlock).
2) To avoid locks, you make threads communicate only read-only data
structures.
3) If you need shared mutable data structures, use the lock-free
collections and queues that the JDK offers. These structures are mutable
but the data items you put in and take out still need to be immutable
"value objects".
4) If you have a big mutable data structure (such as the GUI, or an
internal state machine, etc.), make a single thread responsible for
maintaining it. Never let other threads write to it, that way lies
madness. If other threads absolutely need to read it, you can use a read
lock on the data structure - but then no other thread may ever wait for
the managing thread, otherwise you risk deadlock.
BTW none of this is related to Kryo. If you have multithreading issues,
it is pretty likely that Kryo is merely the victim.
HTH
Jo
Am 26.06.20 um 08:29 schrieb Giuseppe Villani:
> <
http://com.esotericsoftware.kryo.io>.Input.require (Input.java:199)
>
com.esotericsoftware.kryo.io
> <
http://com.esotericsoftware.kryo.io>.Input.readVarInt
> (Input.java:373)
> com.esotericsoftware.kryo.util.DefaultClassResolver.readClass
> (DefaultClassResolver.java:127)
> com.esotericsoftware.kryo.Kryo.readClass (Kryo.java:693)
> com.esotericsoftware.kryo.serializers.ObjectField.read
> (ObjectField.java:118)
> com.esotericsoftware.kryo.serializers.FieldSerializer.read
> (FieldSerializer.java:543)
> com.esotericsoftware.kryo.Kryo.readObject (Kryo.java:712)
>
>
> I understand that the problem might be related to the
> interaction between the two library, but I would like to try to
> fix the problem on that library and hopefully you can give me
> some hints about what can be the cause of the problem.
>
> --
> You received this message because you are subscribed to the "kryo-users"
> group.
>
http://groups.google.com/group/kryo-users
> ---
> You received this message because you are subscribed to the Google
> Groups "kryo-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
kryo-users+...@googlegroups.com
> <mailto:
kryo-users+...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/kryo-users/1f518bce-58cc-4bc6-900b-916baa93e6f1n%40googlegroups.com
> <
https://groups.google.com/d/msgid/kryo-users/1f518bce-58cc-4bc6-900b-916baa93e6f1n%40googlegroups.com?utm_medium=email&utm_source=footer>.