davemorrissey / subsampling-scale-image-view

Android library (AAR). Highly configurable, easily extendable deep zoom view for displaying huge images without loss of detail. Perfect for photo galleries, maps, building plans etc.
Apache License 2.0
7.86k stars 1.2k forks source link

App Crash when setting same bitmap again. #545

Open mostafaimran opened 3 years ago

mostafaimran commented 3 years ago

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)

MarekMacko commented 3 years ago

Any update?

mostafaimran commented 3 years ago

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.

davemorrissey commented 2 years ago

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.