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

ANR in Android from Screenshot #3647

Open
JRomeroCar opened this issue Aug 20, 2024 · 2 comments
Open

ANR in Android from Screenshot #3647

JRomeroCar opened this issue Aug 20, 2024 · 2 comments
Labels
Platform: Android Type: Bug Something isn't working

Comments

@JRomeroCar
Copy link

JRomeroCar commented Aug 20, 2024

Integration

sentry-android

Build System

Gradle

AGP Version

8.1.1

Proguard

Enabled

Version

4.5.1

Steps to Reproduce

Direct operation

Expected Result

No ANR

Actual Result

Image

  main (native):tid=1 systid=18806 
#00 pc 0x89730 libc.so (syscall + 32) (BuildId: 68a68ca7f3b5f0855cb4842d8ccd258e)
#01 pc 0x232670 libart.so (art::ConditionVariable::WaitHoldingLocks + 140) (BuildId: 2452917c4ff69cbb6e75e5512260946b)
#02 pc 0x6be854 libart.so (art::JNI<false>::SetByteArrayRegion + 1692) (BuildId: 2452917c4ff69cbb6e75e5512260946b)
#03 pc 0x2167e8 libhwui.so (SkJavaOutputStream::write + 116) (BuildId: a747ddbc7c084af82b716a41a91c3357)
#04 pc 0x3ffaa4 libhwui.so (sk_write_fn + 52) (BuildId: a747ddbc7c084af82b716a41a91c3357)
#05 pc 0x31d0c libpng.so (png_compress_IDAT + 560) (BuildId: 1f5d2db6586c5a1002e07d4da15b2d2c)
#06 pc 0x35ac0 libpng.so (png_write_find_filter + 1472) (BuildId: 1f5d2db6586c5a1002e07d4da15b2d2c)
#07 pc 0x2e8c4 libpng.so (png_write_row + 828) (BuildId: 1f5d2db6586c5a1002e07d4da15b2d2c)
#08 pc 0x2e568 libpng.so (png_write_rows + 48) (BuildId: 1f5d2db6586c5a1002e07d4da15b2d2c)
#09 pc 0x400780 libhwui.so (SkPngEncoder::onEncodeRows + 224) (BuildId: a747ddbc7c084af82b716a41a91c3357)
#10 pc 0x3fea8c libhwui.so (SkEncoder::encodeRows + 72) (BuildId: a747ddbc7c084af82b716a41a91c3357)
#11 pc 0x400a1c libhwui.so (SkPngEncoder::Encode + 524) (BuildId: a747ddbc7c084af82b716a41a91c3357)
#12 pc 0x3fe984 libhwui.so (SkEncodeImage + 104) (BuildId: a747ddbc7c084af82b716a41a91c3357)
#13 pc 0x3fe880 libhwui.so (SkEncodeImage + 96) (BuildId: a747ddbc7c084af82b716a41a91c3357)
#14 pc 0x241a68 libhwui.so (android::Bitmap::compress + 360) (BuildId: a747ddbc7c084af82b716a41a91c3357)
#15 pc 0x20e64c libhwui.so (Bitmap_compress + 84) (BuildId: a747ddbc7c084af82b716a41a91c3357)
       at android.graphics.Bitmap.nativeCompress(Native method)
       at android.graphics.Bitmap.compress(Bitmap.java:1472)
       at io.sentry.android.core.internal.util.ScreenshotUtils.takeScreenshot(ScreenshotUtils.java:139)
       at io.sentry.android.core.ScreenshotEventProcessor.process(ScreenshotEventProcessor.java:91)
       at io.sentry.SentryClient.processEvent(SentryClient.java:381)
       at io.sentry.SentryClient.captureEvent(SentryClient.java:142)
       at io.sentry.Hub.captureEventInternal(Hub.java:120)
       at io.sentry.Hub.captureEvent(Hub.java:90)
       at io.sentry.Sentry.captureEvent(Sentry.java:525)
       at io.sentry.HubAdapter.captureEvent(HubAdapter.java:30)
       at io.sentry.IHub.captureEvent(IHub.java:40)
       at io.sentry.android.timber.SentryTimberTree.captureEvent(SentryTimberTree.kt:272)
       at io.sentry.android.timber.SentryTimberTree.logWithSentry(SentryTimberTree.kt:240)
       at io.sentry.android.timber.SentryTimberTree.e(SentryTimberTree.kt:146)
       at timber.log.Timber$Forest.e(Timber.kt:342)
       at tv.accedo.elevate.ui.modular.module.ContainersStateManager.handleFetchFailure(ContainersStateManager.java:229)
       at tv.accedo.elevate.ui.modular.module.ContainersStateManager.access$handleFetchFailure(ContainersStateManager.java:40)
       at tv.accedo.elevate.ui.modular.module.ContainersStateManager$fetchSingleContainer$4.emit(ContainersStateManager.kt:207)
       at kotlinx.coroutines.flow.internal.SafeCollectorKt$emitFun$1.invoke(SafeCollector.kt:15)
       at kotlinx.coroutines.flow.internal.SafeCollectorKt$emitFun$1.invoke(SafeCollector.kt:15)
       at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:87)
       at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:66)
       at tv.accedo.elevate.domain.usecase.GetAssetsFromContainerUseCase$invoke$1.invokeSuspend(GetAssetsFromContainerUseCase.kt:46)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
       at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
       at android.os.Handler.handleCallback(Handler.java:984)
       at android.os.Handler.dispatchMessage(Handler.java:104)
       at android.os.Looper.loopOnce(Looper.java:238)
       at android.os.Looper.loop(Looper.java:357)
       at android.app.ActivityThread.main(ActivityThread.java:8149)
       at java.lang.reflect.Method.invoke(Native method)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:957)
@kahest
Copy link
Member

kahest commented Aug 26, 2024

@JRomeroCar thanks for reporting. Some thoughts @markushi

  • the likely culprit is this bitmap.compress running on main thread
    • we initialize the bitmap with ARGB_8888 but I think we don't need 32bit, and likely also no transparency, so RGB_565 could be a faster and cheaper (memory-wise) alternative
    • I know we need to ensure drawing is done on UI thread, but can we offload .compress (and potentially other things) to a background thread?

@markushi
Copy link
Member

@JRomeroCar thanks for bringing this up! We likely can't get rid of creating the bitmap on the main thread, but at least the image compression should be done on a background thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android Type: Bug Something isn't working
Projects
Status: No status
Status: Todo
Development

No branches or pull requests

4 participants