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

Invoke error display on main thread to avoid crashing #1703

Merged
merged 1 commit into from Sep 9, 2021

Conversation

Johnny-Malizia
Copy link
Contributor

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

@homeassistant
Copy link
Contributor

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.
@homeassistant
Copy link
Contributor

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!

@Johnny-Malizia Johnny-Malizia changed the title Invoke error display on main thread to avoid crsahing Invoke error display on main thread to avoid crashing Sep 8, 2021
Copy link
Member

@dshokouhi dshokouhi left a 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)

@JBassett JBassett merged commit 6c573f1 into home-assistant:master Sep 9, 2021
@Johnny-Malizia
Copy link
Contributor Author

@dshokouhi no problem, thanks for the quick attention and helping get this merged.

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.

None yet

4 participants