Skip to content
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

Only add next subscription if control is not null #2812

Merged
merged 2 commits into from
Aug 30, 2022

Conversation

dshokouhi
Copy link
Member

Summary

Noticed the following sentry error generating about 10k events, not really sure what triggers it as I could not reproduce but I also don't think we should be passing a null control over. Assuming of course the control in this case is null. Ran some tests in the emulator and was able to add controls so probably just a sane null check is all that is needed 😃

FWIW this error was first discovered in 2022.1.1

android.os.DeadObjectException: null
    at android.os.BinderProxy.transactNative(BinderProxy.java)
    at android.os.BinderProxy.transact(BinderProxy.java:584)
    at android.service.controls.IControlsSubscriber$Stub$Proxy.onNext(IControlsSubscriber.java:183)
    at android.service.controls.ControlsProviderService$SubscriberProxy.onNext(ControlsProviderService.java:292)
    at android.service.controls.ControlsProviderService$SubscriberProxy.onNext(ControlsProviderService.java:256)
    at io.homeassistant.companion.android.controls.HaControlsProviderService$createPublisherFor$1$1$request$1$2$1.emit(HaControlsProviderService.kt:168)
    at io.homeassistant.companion.android.controls.HaControlsProviderService$createPublisherFor$1$1$request$1$2$1.emit(HaControlsProviderService.kt:160)
    at io.homeassistant.companion.android.common.data.integration.impl.IntegrationRepositoryImpl$getEntityUpdates$$inlined$map$1$2.emit(Emitters.kt:224)
    at io.homeassistant.companion.android.common.data.integration.impl.IntegrationRepositoryImpl$getEntityUpdates$$inlined$filter$1$2.emit(Emitters.kt:224)
    at kotlinx.coroutines.flow.SharedFlowImpl.collect$suspendImpl(SharedFlow.kt:383)
    at kotlinx.coroutines.flow.SharedFlowImpl$collect$1.invokeSuspend
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
java.lang.RuntimeException: android.os.DeadObjectException
    at android.service.controls.ControlsProviderService$SubscriberProxy.onNext(ControlsProviderService.java:294)
    at android.service.controls.ControlsProviderService$SubscriberProxy.onNext(ControlsProviderService.java:256)
    at io.homeassistant.companion.android.controls.HaControlsProviderService$createPublisherFor$1$1$request$1$2$1.emit(HaControlsProviderService.kt:168)
    at io.homeassistant.companion.android.controls.HaControlsProviderService$createPublisherFor$1$1$request$1$2$1.emit(HaControlsProviderService.kt:160)
    at io.homeassistant.companion.android.common.data.integration.impl.IntegrationRepositoryImpl$getEntityUpdates$$inlined$map$1$2.emit(Emitters.kt:224)
    at io.homeassistant.companion.android.common.data.integration.impl.IntegrationRepositoryImpl$getEntityUpdates$$inlined$filter$1$2.emit(Emitters.kt:224)
    at kotlinx.coroutines.flow.SharedFlowImpl.collect$suspendImpl(SharedFlow.kt:383)
    at kotlinx.coroutines.flow.SharedFlowImpl$collect$1.invokeSuspend
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)

Screenshots

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#

Any other notes

@jpelgrom
Copy link
Member

Null controls should happen earlier in the stacktrace and throw a NullPointerException: https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/service/controls/ControlsProviderService.java#282

(Still a good idea to make sure the app doesn't try to provide a null control, but don't forget the call in sendEntitiesToSubscriber.)

@JBassett JBassett merged commit 6e647cb into home-assistant:master Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants