Sentry error: Null Pointer Exception for subscribeTo state changes
Home Assistant Android version:
beta-2692
Android version:
12
Phone model:
SM-F936U1
Home Assistant version:
unknown
Last working Home Assistant release (if known):
unknown
Description of problem:
Found the following sentry error that started to show up in the latest beta in the play store, not impacting too many users but more than just a few.
Traceback (if applicable, to get the logs you may refer to: https://companion.home-assistant.io/docs/troubleshooting/faqs/#android-crash-logs):
java.lang.NullPointerException: null
at io.homeassistant.companion.android.common.data.websocket.impl.WebSocketRepositoryImpl.subscribeTo(WebSocketRepositoryImpl.kt:256)
at io.homeassistant.companion.android.common.data.websocket.impl.WebSocketRepositoryImpl.subscribeToTrigger(WebSocketRepositoryImpl.kt:203)
at io.homeassistant.companion.android.common.data.websocket.impl.WebSocketRepositoryImpl.getStateChanges(WebSocketRepositoryImpl.kt:182)
at io.homeassistant.companion.android.common.data.integration.impl.IntegrationRepositoryImpl.getEntityUpdates(IntegrationRepositoryImpl.kt:615)
at io.homeassistant.companion.android.widgets.BaseWidgetProvider$onScreenOn$1.invokeSuspend(BaseWidgetProvider.kt:108)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:33)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8855)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
Screenshot of problem:
Additional information:
Another race condition? Guess the changes in #2855 weren't enough... I'm tempted to just remove the !! to prevent crashes.
yea this one got triggered when the screen turned on as well
Managed to reproduce this by introducing an artificial delay right before this line. I'm not sure how realistic it is, but the flow isn't removed anywhere else. The device would have to be sending an unsubscribe, which sets the flow to null, and almost immediately resubscribe before the ID is removed in the next line - maybe the system isn't sending the screen off intent immediately or suspending the app too soon?