android.renderscript.RSInvalidStateException
Please include:
- Library version version-2.0.3
- Device and OS version 华为手机 ,安卓10
- Detailed steps to reproduce the issue
- XML layout and code for BlurView setup <eightbitlab.com.blurview.BlurView android:id="@+id/blurView" android:layout_width="match_parent" android:layout_height="match_parent" />
blurView.setupWith(binding.root, RenderScriptBlur(requireContext())).setBlurRadius(10f) blurView.visibleOrGone(true)
- Stacktrace in case of a crash android.renderscript.RSInvalidStateException Calling RS with no Context active.
android.renderscript.RenderScript.validate(RenderScript.java:1252)
android.renderscript.RenderScript.validate(RenderScript.java:1252) 2 android.renderscript.Allocation.createFromBitmap(Allocation.java:2798) 3 android.renderscript.Allocation.createFromBitmap(Allocation.java:3063) 4 eightbitlab.com.blurview.RenderScriptBlur.blur(RenderScriptBlur.java:57) 5 eightbitlab.com.blurview.PreDrawBlurController.blurAndSave(PreDrawBlurController.java:172) 6 eightbitlab.com.blurview.PreDrawBlurController.updateBlur(PreDrawBlurController.java:122) 7 eightbitlab.com.blurview.PreDrawBlurController$1.onPreDraw(PreDrawBlurController.java:50) 8 android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1098) 9 android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3375) 10 android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2166) 11 android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8887) 12 android.view.Choreographer$CallbackRecord.run(Choreographer.java:1280) 13 android.view.Choreographer.doCallbacks(Choreographer.java:1019) 14 android.view.Choreographer.doFrame(Choreographer.java:911) 15 android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1248) 16 android.os.Handler.handleCallback(Handler.java:900) 17 android.os.Handler.dispatchMessage(Handler.java:103) 18 android.os.Looper.loop(Looper.java:219) 19 android.app.ActivityThread.main(ActivityThread.java:8668) 20 java.lang.reflect.Method.invoke(Native Method) 21 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) 22 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)
If you're using Glide or some other image loading library, the cause might be this
I have already read it, and its solution seems to be to download the source code of glide-transformations and modify the source code of the RSBlur class. It seems a bit troublesome. Is there a better solution?
@wang0826jj
You can wrap the RenderscriptBlur, try-catch the blur method and recreate the blur Algorithm on exception.
But really Glide should just fix this, calling releaseAllContexts in a library is outrageous.