AppLovin / AppLovin-MAX-SDK-Android

Other
233 stars 104 forks source link

android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. Expected: main Calling: AppLovinSdk:shared_thread_pool #709

Closed ashakirov closed 2 months ago

ashakirov commented 2 months ago

MAX SDK Version

12.6.1

Device/Platform Info

Android 14

Current Behavior

There is bug in AppLovinMediaView class. It calls removeAllViews method from wrong thread (from AppLovinSdk:shared_thread_pool). But call have to be done from main thread because this call is trying to change view hierarchy.

Here is full stacktrace:

[MediationAdapterWrapper] Failed operation destroy for APPLOVIN_NETWORK android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. Expected: main Calling: AppLovinSdk:shared_thread_pool at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:9994) at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:2082) at android.view.View.requestLayout(View.java:27043) at android.view.View.requestLayout(View.java:27043) at android.view.View.requestLayout(View.java:27043) at android.view.View.requestLayout(View.java:27043) at android.view.View.requestLayout(View.java:27043) at android.view.View.requestLayout(View.java:27043) at android.view.View.requestLayout(View.java:27043) at android.view.View.requestLayout(View.java:27043) at android.view.View.requestLayout(View.java:27043) at androidx.constraintlayout.widget.ConstraintLayout.requestLayout(ConstraintLayout.java:3146) at android.view.View.requestLayout(View.java:27043) at android.view.View.requestLayout(View.java:27043) at android.view.View.requestLayout(View.java:27043) at androidx.constraintlayout.widget.ConstraintLayout.requestLayout(ConstraintLayout.java:3146) at android.view.View.requestLayout(View.java:27043) at android.widget.HorizontalScrollView.requestLayout(HorizontalScrollView.java:1691) at android.view.View.requestLayout(View.java:27043) at android.view.View.requestLayout(View.java:27043) at android.view.ViewGroup.removeAllViews(ViewGroup.java:5759) at com.applovin.impl.sdk.nativeAd.AppLovinMediaView.destroy(SourceFile:4) at com.applovin.impl.sdk.nativeAd.AppLovinNativeAdImpl.unregisterViewsForInteraction(SourceFile:31) at com.applovin.impl.sdk.nativeAd.AppLovinNativeAdImpl.destroy(SourceFile:1) at com.applovin.mediation.adapters.AppLovinMediationAdapter.onDestroy(SourceFile:15) at com.applovin.impl.mediation.g.l(SourceFile:3) at com.applovin.impl.mediation.g.$r8$lambda$M0-41Qz0EJAwuzvMp176QgZnzQA(Unknown Source:0) at com.applovin.impl.mediation.g$$ExternalSyntheticLambda11.run(D8$$SyntheticClass:0) at com.applovin.impl.mediation.g.a(SourceFile:5870) at com.applovin.impl.mediation.g.$r8$lambda$Bzit5t9eqfA6lP9x96YlsSo49TU(Unknown Source:0) at com.applovin.impl.mediation.g$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0) at com.applovin.impl.jn.run(SourceFile:46) at com.applovin.impl.tm$d.run(SourceFile:24) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:487) at java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:307) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) at java.lang.Thread.run(Thread.java:1012)

Here is screenshot from debugger: Screenshot_64

Expected Behavior

No response

How to Reproduce

  1. load native banner via MaxNativeAdLoader.loadAd method
  2. destroy native banner via calling MaxNativeAdLoader.destroy (call it from main thread).

Additional Info

No response

tiandrew commented 2 months ago

Hey @ashakirov, thanks for flagging this. We have a fix in our upcoming SDK release for this issue. We'll notify you in this thread when it's released.

tiandrew commented 2 months ago

@ashakirov our latest SDK release has a fix for this issue.