socketio / socket.io-client-java

Full-featured Socket.IO Client Library for Java, which is compatible with Socket.IO v1.0 and later.
https://socketio.github.io/socket.io-client-java/installation.html
Other
5.32k stars 972 forks source link

[Crash] I have a crash in EventThread when using R8 #685

Open kimdew0912 opened 2 years ago

kimdew0912 commented 2 years ago

Hi! Our product is using your socket io library and we are really satisfied with the library.

But, I faced a crash in EventThread below when using R8.

09-30 16:27:57.634 E/AndroidRuntime(14071): java.lang.NullPointerException
09-30 16:27:57.634 E/AndroidRuntime(14071):     at java.util.Objects.requireNonNull(Objects.java:203)
09-30 16:27:57.634 E/AndroidRuntime(14071):     at io.socket.thread.EventThread$2.run(chromium-WhalePublic.apk-default-1144:9)
09-30 16:27:57.634 E/AndroidRuntime(14071):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
09-30 16:27:57.634 E/AndroidRuntime(14071):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
09-30 16:27:57.634 E/AndroidRuntime(14071):     at java.lang.Thread.run(Thread.java:919)

I'm using the engine and client version 1.0.0 and I faced this crash after my app applied R8. It seems that the crash occurred after connecting socket or when handling some Runnable in EventThread.

So, I'm trying to solve it in several ways, but I couldn't fix the issue. Even though I added some rules like this -keep class io.socket.** { *; } to my proguard file, still faced the same issue.

I know this issue can be caused by our build environment possibly, but I haven't been resolving it as mentioned. Could you help me about the crash by any chance?

kimdew0912 commented 2 years ago

I resolved this issue.

The reason of the NPE is that java.util.logging.Logger was discarded in R8. So I resolved this issue by removing the discard logic in our proguard rule file.

But you need to check every logic related to Logger because some logics are missing the if (Logger.isLoggable(Level.FINE)).

(If you admin, please close this issue.)