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

android.renderscript.RSInvalidStateException #202

Closed
Jankin6 opened this issue Aug 2, 2023 · 3 comments
Closed

android.renderscript.RSInvalidStateException #202

Jankin6 opened this issue Aug 2, 2023 · 3 comments

Comments

@Jankin6
Copy link

Jankin6 commented Aug 2, 2023

Please include:

  1. Library version
    version-2.0.3
  2. Device and OS version
    华为手机 ,安卓10
  3. Detailed steps to reproduce the issue
  4. 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)

  1. 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)

@Dimezis
Copy link
Owner

Dimezis commented Aug 2, 2023

If you're using Glide or some other image loading library, the cause might be this

@Jankin6
Copy link
Author

Jankin6 commented Aug 3, 2023

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?

@Dimezis
Copy link
Owner

Dimezis commented Aug 5, 2023

@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.

@Dimezis Dimezis closed this as completed May 11, 2024
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

2 participants