1

Hi I have this weird problem. The main reason that i am writing this question is that this exception is not referencing to my code but it has references just to core android libraries. How can i determine which bitmap is recycled and want to be used? It happens mainy on samsung galaxy s5.I have also checked the id 30c3578e at my whole project in generated files too but i found nothing. Can this be in Android?

java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@30c3578e 

    --------- Stack trace ---------

        android.graphics.Canvas.throwIfCannotDraw(Canvas.java:1225) 
        android.view.GLES20Canvas.drawBitmap(GLES20Canvas.java:600) 
        android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:543) 
        android.widget.ImageView.onDraw(ImageView.java:1187) 
        android.view.View.draw(View.java:16060) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.view.View.draw(View.java:16063) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.view.View.draw(View.java:16063) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.widget.ListView.drawChild(ListView.java:3462) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.widget.AbsListView.dispatchDraw(AbsListView.java:3103) 
        android.widget.ListView.dispatchDraw(ListView.java:3457) 
        android.view.View.draw(View.java:16063) 
        android.widget.AbsListView.draw(AbsListView.java:5989) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.view.View.draw(View.java:16063) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.view.View.draw(View.java:16063) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.view.View.draw(View.java:16063) 
        android.widget.FrameLayout.draw(FrameLayout.java:592) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.view.View.draw(View.java:16063) 
        android.support.v4.view.ViewPager.draw(ViewPager.java:2176) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.view.View.draw(View.java:16063) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java:1060) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.view.View.draw(View.java:16063) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.view.View.draw(View.java:16063) 
        android.widget.FrameLayout.draw(FrameLayout.java:592) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.view.View.draw(View.java:16063) 
        com.android.internal.widget.ActionBarOverlayLayout.draw(ActionBarOverlayLayout.java:501) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.View.draw(View.java:15781) 
        android.view.ViewGroup.drawChild(ViewGroup.java:3677) 
        android.view.ViewGroup.dispatchDraw(ViewGroup.java:3471) 
        android.view.View.draw(View.java:16063) 
        android.widget.FrameLayout.draw(FrameLayout.java:592) 
        com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2916) 
        android.view.View.updateDisplayListIfDirty(View.java:14991) 
        android.view.View.getDisplayList(View.java:15014) 
        android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:275) 
        android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:281) 
        android.view.ThreadedRenderer.draw(ThreadedRenderer.java:320) 
        android.view.ViewRootImpl.draw(ViewRootImpl.java:2741) 
        android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2573) 
        android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2165) 
        android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1180) 
        android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6558) 
        android.view.Choreographer$CallbackRecord.run(Choreographer.java:777) 
        android.view.Choreographer.doCallbacks(Choreographer.java:590) 
        android.view.Choreographer.doFrame(Choreographer.java:560) 
        android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763) 
        android.os.Handler.handleCallback(Handler.java:739) 
        android.os.Handler.dispatchMessage(Handler.java:95) 
        android.os.Looper.loop(Looper.java:145) 
        android.app.ActivityThread.main(ActivityThread.java:5832) 
        java.lang.reflect.Method.invoke(Native Method) 
        java.lang.reflect.Method.invoke(Method.java:372) 
        com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) 
        com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) 

1 Answer 1

1

First of all you should provide your code, if you want us to make an investigation.

Second you can check your bitmap before:

bitmap.isRecycled();

Returns true if this bitmap has been recycled. If so, then it is an error to try to access its pixels, and the bitmap will not draw.

Sign up to request clarification or add additional context in comments.

2 Comments

I check all of the bitmaps to isRecycled and not null and i recycle them only at onDestroy. The error does not reference on any line of my code neither on class where it can happened and unfortunatelly i am not able to show you the whole project.
Activity.onDestroy() can be called in 2 cases: This can happen either because the activity is finishing (someone called finish() on it, or because the system is temporarily destroying this instance of the activity to save space, in this case onCreate() will be called again with not null savedInstanceState, may be this is the reason you getting recycled bitmaps. You can reproduce it with Don't Keep Activities (in settings->developer).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.