question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Calling RS with no context active

See original GitHub issue

Hi,

Blurview v. 1.3.4

Been using this library for months. Just started getting this error.

Fatal Exception: android.renderscript.RSInvalidStateException: Calling RS with no Context active.
       at android.renderscript.RenderScript.validate(RenderScript.java:1237)
       at android.renderscript.Allocation.createFromBitmap(Allocation.java:2798)
       at android.renderscript.Allocation.createFromBitmap(Allocation.java:3062)
       at eightbitlab.com.blurview.RenderScriptBlur.blur(RenderScriptBlur.java:47)
       at eightbitlab.com.blurview.BlockingBlurController.blurAndSave(BlockingBlurController.java:1241)
       at eightbitlab.com.blurview.BlurView.draw(BlurView.java:57)
       at android.view.View.updateDisplayListIfDirty(View.java:16200)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3758)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3738)
       at android.view.View.updateDisplayListIfDirty(View.java:16163)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3758)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3738)
       at android.view.View.updateDisplayListIfDirty(View.java:16163)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3758)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3738)
       at android.view.View.updateDisplayListIfDirty(View.java:16163)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3758)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3738)
       at android.view.View.updateDisplayListIfDirty(View.java:16163)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3758)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3738)
       at android.view.View.updateDisplayListIfDirty(View.java:16163)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3758)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3738)
       at android.view.View.updateDisplayListIfDirty(View.java:16163)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3758)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3738)
       at android.view.View.updateDisplayListIfDirty(View.java:16163)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3758)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3738)
       at android.view.View.updateDisplayListIfDirty(View.java:16163)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3758)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3738)
       at android.view.View.updateDisplayListIfDirty(View.java:16163)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3758)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3738)
       at android.view.View.updateDisplayListIfDirty(View.java:16163)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3758)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3738)
       at android.view.View.updateDisplayListIfDirty(View.java:16163)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3758)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3738)
       at android.view.View.updateDisplayListIfDirty(View.java:16163)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3758)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3738)
       at android.view.View.updateDisplayListIfDirty(View.java:16163)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3758)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3738)
       at android.view.View.updateDisplayListIfDirty(View.java:16163)
       at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3758)
       at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3738)
       at android.view.View.updateDisplayListIfDirty(View.java:16163)
       at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:676)
       at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:682)
       at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:796)
       at android.view.ViewRootImpl.draw(ViewRootImpl.java:2989)
       at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2783)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2374)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1364)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6763)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:923)
       at android.view.Choreographer.doCallbacks(Choreographer.java:735)
       at android.view.Choreographer.doFrame(Choreographer.java:667)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:909)
       at android.os.Handler.handleCallback(Handler.java:761)
       at android.os.Handler.dispatchMessage(Handler.java:98)
       at android.os.Looper.loop(Looper.java:156)
       at android.app.ActivityThread.main(ActivityThread.java:6524)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)

Any idea?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Dimeziscommented, May 5, 2022

glide-transformations should just stop calling releaseAllContexts. It can break more than this library

1reaction
Dimeziscommented, Feb 22, 2018

So I spent quite a lot of time investigating this crash.

The conclusion is - from library’s POV it’s impossible to call RS without context, at least on API 23+. I’m obtaining it in BlurAlgorithm’s constructor to use in the same object. Eventually, destroy() is called on RS and I thought it could be an issue in certain cases if you are accidentally reusing the same BlurAlgorithm. But, on API 23+ destroy() is a no-op, because of changes in SDK.

So I have only couple of potential explanations to the problem:

  1. Some vendors changed RS API and something doesn’t correspond to official documentation.
  2. RS Context can be destroyed implicitly by SDK in some weird cases and I have no control over it. For example, from RS sources it seems like it can happen during GC of Renderscipt object.
  3. You have some memory leaks or duplicated BlurViews or BlurAlgorithms which you are not aware of and it causes some issues, theoretically related to point 2.

Long story short, at this point I’m not able to fix it, and I have only 3 suggestions for you:

  1. You can use a workaround I provided in post above, with custom BlurAlgorithm and try-catch
  2. Give a try to com.eightbitlab:supportrenderscriptblur, maybe Support Renderscript doesn’t have this issue.
  3. Set up Strict Mode to check if there’s only 1 instance of BlurView and RenderscriptBlur at a time.
Read more comments on GitHub >

github_iconTop Results From Across the Web

RSInvalidStateException with RenderScript on Android
I've seen this on some old devices, it's a bug. It's not a bug in the code above. However, there is a major...
Read more >
RSInvalidStateException - Android Developers
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. final Class<?> ......
Read more >
rs/java/android/renderscript/RenderScript.java - Google Git
This class provides access to a RenderScript context, which controls RenderScript ... throw new RSInvalidStateException("Calling RS with no Context active.
Read more >
Bug: cannot instantiate RenderScript on [37056129]
RSRuntimeException: Failure to create platform RenderScript context at android.app. ... RSInvalidStateException: Calling RS with no Context active.
Read more >
JAX-RS No application context active seam 2.1 - JBoss.org
CategoryAction.class, true); The error occurs trying to call 'Component.getInstance'... The non-seam aspect of the service works just no seam ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found