[android] Don't crash the app if native client fails to init#10
Open
edenman wants to merge 1 commit intojuicebox-systems:mainfrom
Open
[android] Don't crash the app if native client fails to init#10edenman wants to merge 1 commit intojuicebox-systems:mainfrom
edenman wants to merge 1 commit intojuicebox-systems:mainfrom
Conversation
Author
|
@Imperiopolis can you take a look please? |
Imperiopolis
requested changes
Mar 4, 2026
In our app we are wrapping the calls to the juicebox SDK in a try/catch
but we are still getting occasional crashes (stacktrace below). This PR
adds a try/catch around both of the launched threads to ensure that the
app does not crash if Client init fails, and adds an optional callback
so callers get notified if the init failed.
```
Fatal Exception: java.net.NoRouteToHostException: Host unreachable
at libcore.io.IoBridge.connect(IoBridge.java:182)
at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)
at java.net.Socket.connect(Socket.java:646)
at com.android.okhttp.internal.Platform.connectSocket(Platform.java:182)
at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:145)
at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:116)
at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:186)
at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:128)
at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:97)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:289)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:232)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:465)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:131)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:262)
at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:219)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:30)
at com.google.firebase.perf.network.InstrURLConnectionBase.getOutputStream(InstrURLConnectionBase.java:165)
at com.google.firebase.perf.network.InstrHttpsURLConnection.getOutputStream(InstrHttpsURLConnection.java:89)
at xyz.juicebox.sdk.Client$Companion$createNative$httpSend$1$1.invoke(Client.kt:163)
at xyz.juicebox.sdk.Client$Companion$createNative$httpSend$1$1.invoke(Client.kt:125)
at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)
```
Author
|
Updated, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In our app we are wrapping the calls to the juicebox SDK in a try/catch but we are still getting occasional crashes (stacktrace below). This PR adds a try/catch around both of the launched threads to ensure that the app does not crash if Client init fails, and adds an optional callback so callers get notified if the init failed.
Fixes #11