-
Notifications
You must be signed in to change notification settings - Fork 154
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
Crash: java.lang.RuntimeException: MulticastLock under-locked react-native-udp #144
Comments
@hubciorz, thanks for your feedback! I don't know what is causing the error, but I am working on switching all multi-thread code to the Java standard API. It might fix your issue. I will create a PR which will close this issue when merged so you are notified. |
@Rapsssito Good to hear that! Good luck and thank you. |
🎉 This issue has been resolved in version 4.0.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@Rapsssito So far so good. No crashes. Tested by about 1000 users. I will let you know if there is any. Many thanks! |
@Rapsssito It seems that crashes happen less frequently, but if they do, stack trace is quite different: com.tradle.react.UdpSockets$6.run
java.lang.RuntimeException: MulticastLock under-locked react-native-udp android.net.wifi.WifiManager$MulticastLock.release WifiManager.java:4291
com.tradle.react.UdpSockets$6.run UdpSockets.java:257
java.lang.Thread.run Thread.java:919
java.util.concurrent.ThreadPoolExecutor.runWorker ThreadPoolExecutor.java:1167
java.util.concurrent.ThreadPoolExecutor$Worker.run ThreadPoolExecutor.java:641
java.lang.Thread.run Thread.java:919 |
@hubciorz could you provide me with an example code so I can reproduce the issue? |
@Rapsssito This is just a standard udp listening code, as I pasted in #143 (btw, this one has been fixed). It's hard to reproduce the bug. A hint - going to background/foreground may be the key. this.udpSocket = createSocket({ type: "udp4", reuseAddr: true })
this.udpSocket.on("message", this.onUdp.bind(this))
this.udpSocket.on("error", this.onUDPError.bind(this))
this.udpSocket.on("listening", this.onUDPListening.bind(this))
this.udpSocket.bind(7979)
private onUDPListening(err) {
if (err) {
log.error("Error when listening on UDP discovering socket:", err)
return
}
if (this.udpSocket) {
log.debug("Setting multicast for socket:", this.udpSocket)
this.udpSocket.setBroadcast(true)
this.udpSocket.addMembership(MULTICAST_GROUP)
} else {
log.debug("Error when setting multicast for socket. Socket is null")
}
}
private onUDPError(err) {
log.error("Error on UDP discovering socket:", err)
}
...
// AppState change detection logic |
@Rapsssito I think it is likely to happen when someone loses wifi connection for a while. Please take a look a these comments: |
Fixed by #148 |
Description
App sometimes crashes after going to background (Android)
Error
Stack traces
Steps to reproduce
Hard to say. It happens very rarely and it seems that you need to go to background at the right moment.
Expected behavior
No crash, perhaps.
Relevant information
Occurred on
The text was updated successfully, but these errors were encountered: