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

Load Drawable can block main thread for over 1 second #5398

Open
benjaminRomano opened this issue Apr 11, 2024 · 0 comments
Open

Load Drawable can block main thread for over 1 second #5398

benjaminRomano opened this issue Apr 11, 2024 · 0 comments

Comments

@benjaminRomano
Copy link
Contributor

Background
We recently added some instrumentation to our app that detects our main thread blocked for >700ms (Android's Frozen Frame definition). We observed that one of our top issues causing main thread blockages / frozen frames is Glide's image loading.

Issue
We are observing that Glide can periodically cause the main thread to get stuck for ~1.5s seconds and in the worst case results in ANRs.

It appears to be an issue primarily on Android versions 9, 10 and 11. From internal data, I don't see anything that indicates that this is device model / OEM-specific.

Screenshot 2024-04-11 at 12 07 09 AM

It's probably unlikely there is enough info to root cause, but this report may help future developers who run into similar problems.

Example Stacktraces

These are the top stacktraces roughly in-order of occurence

	at android.content.res.AssetManager.nativeSetApkAssets(Native Method)
	at android.content.res.AssetManager.access$300(AssetManager.java:64)
	at android.content.res.AssetManager$Builder.build(AssetManager.java:161)
	at android.app.ResourcesManager.createAssetManager(ResourcesManager.java:435)
	at android.app.ResourcesManager.originalCreateResourcesImpl(ResourcesManager.java:529)
	at android.app.ResourcesManager.createResourcesImpl(ResourcesManager.java:520)
	at android.app.ResourcesManager.getOrCreateResources(ResourcesManager.java:831)
	at android.app.ResourcesManager.getResources(ResourcesManager.java:897)
	at android.app.ContextImpl.createResources(ContextImpl.java:2147)
	at android.app.ContextImpl.createConfigurationContext(ContextImpl.java:2254)
	at android.content.ContextWrapper.createConfigurationContext(ContextWrapper.java:919)
	at android.content.ContextWrapper.createConfigurationContext(ContextWrapper.java:919)
	at androidx.appcompat.view.ContextThemeWrapper.getResourcesInternal(ContextThemeWrapper.java)
	at androidx.appcompat.view.ContextThemeWrapper.getResources(ContextThemeWrapper.java)
	at androidx.appcompat.widget.ResourceManagerInternal.createDrawableIfNeeded(ResourceManagerInternal.java)
	at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java)
	at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java)
	at androidx.appcompat.content.res.AppCompatResources.getDrawable(AppCompatResources.java)
	at com.bumptech.glide.load.resource.drawable.DrawableDecoderCompat.loadDrawableV7(DrawableDecoderCompat.java)
	at com.bumptech.glide.load.resource.drawable.DrawableDecoderCompat.getDrawable(DrawableDecoderCompat.java)
	at com.bumptech.glide.load.resource.drawable.DrawableDecoderCompat.getDrawable(DrawableDecoderCompat.java)
	at android.hardware.display.DisplayManagerGlobal.getDisplayInfo(DisplayManagerGlobal.java:233)
	at android.hardware.display.DisplayManagerGlobal.getCompatibleDisplay(DisplayManagerGlobal.java:382)
	at android.app.ResourcesManager.getAdjustedDisplay(ResourcesManager.java:458)
	at android.app.ContextImpl.getDisplayNoVerify(ContextImpl.java:3206)
	at android.app.ContextImpl.getDisplayId(ContextImpl.java:3215)
	at android.app.ContextImpl.createConfigurationContext(ContextImpl.java:2885)
	at android.content.ContextWrapper.createConfigurationContext(ContextWrapper.java:1153)
	at android.content.ContextWrapper.createConfigurationContext(ContextWrapper.java:1153)
	at androidx.appcompat.view.ContextThemeWrapper.getResourcesInternal(ContextThemeWrapper.java)
	at androidx.appcompat.view.ContextThemeWrapper.getResources(ContextThemeWrapper.java)
	at androidx.appcompat.widget.ResourceManagerInternal.c(ResourceManagerInternal.java:15)
	at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java)
	at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java)
	at androidx.appcompat.content.res.AppCompatResources.getDrawable(AppCompatResources.java)
	at com.bumptech.glide.load.resource.drawable.DrawableDecoderCompat.loadDrawableV7(DrawableDecoderCompat.java)
	at com.google.android.gms.internal.mlkit_vision_common.zzjm.j(com.google.mlkit:vision-common@@17.3.0:5)
	at com.bumptech.glide.load.resource.drawable.DrawableDecoderCompat.getDrawable(DrawableDecoderCompat.java)
	at android.app.ContextImpl.getTheme(ContextImpl.java:310)
	at android.content.ContextWrapper.getTheme(ContextWrapper.java:125)
	at com.bumptech.glide.request.SingleRequest.loadDrawable(SingleRequest.java)
	at com.bumptech.glide.request.SingleRequest.getPlaceholderDrawable(SingleRequest.java)
	at com.bumptech.glide.request.SingleRequest.begin(SingleRequest.java)
	at com.bumptech.glide.manager.RequestTracker.runRequest(RequestTracker.java)
	at com.bumptech.glide.RequestManager.track(RequestManager.java)
	at com.bumptech.glide.RequestBuilder.into(RequestBuilder.java)
	at com.bumptech.glide.RequestBuilder.into(RequestBuilder.java)
	at com.bumptech.glide.RequestBuilder.into(RequestBuilder.java)
	at com.snap.imageloading.internal.glide4.impl.Glide4ImageView$loadBitmap$1.run(Glide4ImageView.java)
	at com.snap.framework.rx.RxExtensions$toSafe$1.run(RxExtensions.java)
	at com.snap.taskexecution.scheduling.AttributedHandlerScheduler.runWorkerScheduledRunnable(AttributedHandlerScheduler.java)
	at android.os.Handler.handleCallback(Handler.java:809)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:166)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant