Baseflow / LottieXamarin

Render After Effects animations natively on Android, iOS, MacOS and TvOS for Xamarin
https://baseflow.com
Apache License 2.0
1.22k stars 261 forks source link

Android - Only the original thread that created a view hierarchy can touch its views #316

Closed pmahend1 closed 3 years ago

pmahend1 commented 3 years ago

🐛 Bug Report

Animation with json is not being loaded up, and when I Navigation.PushAsync or Navigation.PopAsync , I get the following error.

android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
    at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:8191)
    at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:1420)
    at android.view.View.requestLayout(View.java:24454)
    at android.view.View.requestLayout(View.java:24454)
    at android.view.View.requestLayout(View.java:24454)
    at android.view.View.requestLayout(View.java:24454)
    at android.view.View.requestLayout(View.java:24454)
    at android.view.View.requestLayout(View.java:24454)
    at android.widget.RelativeLayout.requestLayout(RelativeLayout.java:380)
    at android.view.View.requestLayout(View.java:24454)
    at android.view.View.requestLayout(View.java:24454)
    at android.view.View.requestLayout(View.java:24454)
    at android.view.View.requestLayout(View.java:24454)
    at androidx.appcompat.widget.ActionMenuPresenter.updateMenuView(ActionMenuPresenter.java:228)
    at androidx.appcompat.view.menu.MenuBuilder.dispatchPresenterUpdate(MenuBuilder.java:292)
    at androidx.appcompat.view.menu.MenuBuilder.onItemsChanged(MenuBuilder.java:1063)
    at androidx.appcompat.view.menu.MenuBuilder.clear(MenuBuilder.java:609)
"></Exception>

Expected behavior

Animations should load with no view related exceptions.

Reproduction steps

Install lottie Try to load an animation with Json through a modal page Close the modal page call Navigation Push or pop

Configuration

Version: 4.0.4

Platform:

pmahend1 commented 3 years ago

Fixed with Device.BeginInvokeOnMainThread