subsampling-scale-image-view icon indicating copy to clipboard operation
subsampling-scale-image-view copied to clipboard

App Crash when setting same bitmap again.

Open mostafaimran opened this issue 4 years ago • 3 comments

Please provide as much of the following information as possible. Please do not raise issues to ask for help developing your app.

Expected behaviour

App should not crash.

Actual behaviour

App crashes when setting same bitmap again. Setting the bitmap first time works perfectly but setting the bitmap again crashes.

Steps to reproduce

Set same bitmap again and crash happens. Crash happens in this line - SubsamplingScaleImageView.onDraw(SubsamplingScaleImageView.java:1111)

(Include your setup code, and where relevant, your layout XML)

Affected devices

Pixel 2

(Specific devices, screen densities, SDK versions)

Affected images

(Attach images you have problems with)

Crash log -- native: #186 pc 0000000000547e50 /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeWithVarArgsart::ArtMethod*(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, std::__va_list)+448) runtime.cc:655] native: #187 pc 000000000054830c /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list)+92) runtime.cc:655] native: #188 pc 0000000000431e24 /apex/com.android.art/lib64/libart.so (art::JNI::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+636) runtime.cc:655] native: #189 pc 0000000000099428 /system/lib64/libandroid_runtime.so (_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+124) runtime.cc:655] native: #190 pc 00000000000a0880 /system/lib64/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vectorandroid::String8 const&, bool)+836) runtime.cc:655] native: #191 pc 0000000000003574 /system/bin/app_process64 (main+1324) runtime.cc:655] native: #192 pc 000000000004973c /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+108) runtime.cc:655] at android.graphics.BaseRecordingCanvas.nDrawBitmapMatrix(Native method) runtime.cc:655] at android.graphics.BaseRecordingCanvas.drawBitmap(BaseRecordingCanvas.java:78) runtime.cc:655] at com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView.onDraw(SubsamplingScaleImageView.java:1111) runtime.cc:655] at com.cloudapper.android.custom.customviews.layoutmap.LayoutMapView.onDraw(LayoutMapView.kt:791) runtime.cc:655] at android.view.View.draw(View.java:22350) runtime.cc:655] at android.view.View.updateDisplayListIfDirty(View.java:21226) runtime.cc:655] at android.view.View.draw(View.java:22081) runtime.cc:655] at android.view.ViewGroup.drawChild(ViewGroup.java:4516) runtime.cc:655] at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277) runtime.cc:655] at android.view.View.updateDisplayListIfDirty(View.java:21217) runtime.cc:655] at android.view.View.draw(View.java:22081) runtime.cc:655] at android.view.ViewGroup.drawChild(ViewGroup.java:4516) runtime.cc:655] at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277) runtime.cc:655] at android.view.View.updateDisplayListIfDirty(View.java:21217) runtime.cc:655] at android.view.View.draw(View.java:22081) runtime.cc:655] at android.view.ViewGroup.drawChild(ViewGroup.java:4516) runtime.cc:655] at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277) runtime.cc:655] at android.view.View.updateDisplayListIfDirty(View.java:21217) runtime.cc:655] at android.view.View.draw(View.java:22081) runtime.cc:655] at android.view.ViewGroup.drawChild(ViewGroup.java:4516) runtime.cc:655] at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277) runtime.cc:655] at android.view.View.draw(View.java:22353) runtime.cc:655] at android.view.View.updateDisplayListIfDirty(View.java:21226) runtime.cc:655] at android.view.View.draw(View.java:22081) runtime.cc:655] at android.view.ViewGroup.drawChild(ViewGroup.java:4516) runtime.cc:655] at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277) runtime.cc:655] at android.view.View.updateDisplayListIfDirty(View.java:21217) runtime.cc:655] at android.view.View.draw(View.java:22081) runtime.cc:655] at android.view.ViewGroup.drawChild(ViewGroup.java:4516) runtime.cc:655] at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277) runtime.cc:655] at android.view.View.updateDisplayListIfDirty(View.java:21217) runtime.cc:655] at android.view.View.draw(View.java:22081) runtime.cc:655] at android.view.ViewGroup.drawChild(ViewGroup.java:4516) runtime.cc:655] at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277) runtime.cc:655] at android.view.View.draw(View.java:22353) runtime.cc:655] at androidx.core.widget.NestedScrollView.draw(NestedScrollView.java:1998)

mostafaimran avatar Feb 17 '21 12:02 mostafaimran

Any update?

MarekMacko avatar May 25 '21 11:05 MarekMacko

I did a workaround to overcome this crash when need to update the view with resetting the bitmap. Each time I am removing and then adding the view to a FrameLayout when I need to update the view with new bitmap.

mostafaimran avatar Jun 07 '21 05:06 mostafaimran

You haven't provided your source so I don't know if you're using ImageSource.cachedBitmap to avoid recycling - but the view shouldn't try to draw a recycled bitmap so I assume you are. If so, I don't see how I could fix this because the crash is deep in native code and all the view does is draw the bitmap it's given.

davemorrissey avatar Sep 22 '21 20:09 davemorrissey