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
Invoke error display on main thread to avoid crashing #1703
Conversation
Hi @Johnny-Malizia, It seems you haven't yet signed a CLA. Please do so here. Once you do that we will be able to review and accept this pull request. Thanks! |
Failing to run the view change on the main thread may cause a CalledFromWrongThread exception as the view may not have been created from a thread in the IO pool.
257f9f7
to
8ea5f4e
Compare
Hi @Johnny-Malizia, It seems you haven't yet signed a CLA. Please do so here. Once you do that we will be able to review and accept this pull request. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution! Found the actual error in Sentry seems a few other users are also hitting this error.
This is the full trace that I see:
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:8029)
at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:1276)
at android.view.View.requestLayout(View.java:23277)
at android.view.View.requestLayout(View.java:23277)
at android.view.View.requestLayout(View.java:23277)
at android.view.View.requestLayout(View.java:23277)
at android.view.View.requestLayout(View.java:23277)
at android.view.View.requestLayout(View.java:23277)
at android.view.View.requestLayout(View.java:23277)
at android.view.View.requestLayout(View.java:23277)
at android.view.View.setFlags(View.java:14155)
at android.view.View.setVisibility(View.java:10005)
at android.widget.ViewAnimator.showOnly(ViewAnimator.java:165)
at android.widget.ViewAnimator.showOnly(ViewAnimator.java:178)
at android.widget.ViewAnimator.setDisplayedChild(ViewAnimator.java:110)
at io.homeassistant.companion.android.onboarding.integration.MobileAppIntegrationFragment.showError(MobileAppIntegrationFragment.kt:134)
at io.homeassistant.companion.android.onboarding.integration.MobileAppIntegrationPresenterBase$onRegistrationAttempt$1.invokeSuspend(MobileAppIntegrationPresenterBase.kt:50)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
@dshokouhi no problem, thanks for the quick attention and helping get this merged. |
Failing to run the view change on the main thread may cause a
CalledFromWrongThread exception as the view may not have been created
from a thread in the IO pool.
Summary
The app was failing to start up for me, I looked into the exception being thrown and it looks like the view is being changed from a different thread than it was created, this change will force the view to be modified by the same context that is used in a successful case.
Screenshots
Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#
Any other notes