Skip to content

Loading cached .zip animation with images fails (and crashes app) #1009

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

Closed
wbonnefond opened this issue Nov 26, 2018 · 1 comment
Closed

Comments

@wbonnefond
Copy link

When a .zip animation with images is loaded from the cache, the library does not reload the bitmaps. The issue happens because the library recycle the bitmaps when the view is detached from the screen. When attempting the load the animation again, it finds it in the cache, but the bitmaps are never reloaded. This causes the app to crash.

Lottie version: 2.7.0
Lottie file: puppy_run.zip
Sample project showcasing the issue: LottieTest.zip

To reproduce:

  1. Run project
  2. Launch LottieActivity with button
  3. Verify Lottie animation runs
  4. Press back
  5. Launch LottieActivity with button
  6. Verify app crashes

The stacktrace is misleading because it assumes you haven't set the image folder, but it only reaches this point because it didn't load the images correctly when the animation is cached.

Stacktrace:

2018-11-26 17:02:00.224 19775-19775/com.wardbonnefond.lottietest E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.wardbonnefond.lottietest, PID: 19775
    java.lang.IllegalStateException: You must set an images folder before loading an image. Set it with LottieComposition#setImagesFolder or LottieDrawable#setImagesFolder
        at com.airbnb.lottie.manager.ImageAssetManager.bitmapForId(ImageAssetManager.java:107)
        at com.airbnb.lottie.LottieDrawable.getImageAsset(LottieDrawable.java:839)
        at com.airbnb.lottie.model.layer.ImageLayer.getBitmap(ImageLayer.java:68)
        at com.airbnb.lottie.model.layer.ImageLayer.drawLayer(ImageLayer.java:32)
        at com.airbnb.lottie.model.layer.BaseLayer.draw(BaseLayer.java:201)
        at com.airbnb.lottie.model.layer.CompositionLayer.drawLayer(CompositionLayer.java:100)
        at com.airbnb.lottie.model.layer.BaseLayer.draw(BaseLayer.java:201)
        at com.airbnb.lottie.LottieDrawable.draw(LottieDrawable.java:319)
        at android.widget.ImageView.onDraw(ImageView.java:1316)
        at android.view.View.draw(View.java:17185)
        at android.view.View.buildDrawingCacheImpl(View.java:16474)
        at android.view.View.buildDrawingCache(View.java:16335)
        at android.view.View.draw(View.java:16943)
        at android.view.ViewGroup.drawChild(ViewGroup.java:3727)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513)
        at android.support.constraint.ConstraintLayout.dispatchDraw(ConstraintLayout.java:2023)
        at android.view.View.updateDisplayListIfDirty(View.java:16162)
        at android.view.View.draw(View.java:16951)
        at android.view.ViewGroup.drawChild(ViewGroup.java:3727)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513)
        at android.view.View.updateDisplayListIfDirty(View.java:16162)
        at android.view.View.draw(View.java:16951)
        at android.view.ViewGroup.drawChild(ViewGroup.java:3727)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513)
        at android.view.View.updateDisplayListIfDirty(View.java:16162)
        at android.view.View.draw(View.java:16951)
        at android.view.ViewGroup.drawChild(ViewGroup.java:3727)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513)
        at android.view.View.updateDisplayListIfDirty(View.java:16162)
        at android.view.View.draw(View.java:16951)
        at android.view.ViewGroup.drawChild(ViewGroup.java:3727)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513)
        at android.view.View.updateDisplayListIfDirty(View.java:16162)
        at android.view.View.draw(View.java:16951)
        at android.view.ViewGroup.drawChild(ViewGroup.java:3727)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513)
        at android.view.View.draw(View.java:17188)
        at com.android.internal.policy.DecorView.draw(DecorView.java:753)
        at android.view.View.updateDisplayListIfDirty(View.java:16167)
        at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:648)
        at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:654)
        at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:762)
        at android.view.ViewRootImpl.draw(ViewRootImpl.java:2800)
        at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2608)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2215)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6337)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
        at android.view.Choreographer.doCallbacks(Choreographer.java:686)
        at android.view.Choreographer.doFrame(Choreographer.java:621)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
        at android.os.Handler.handleCallback(Handler.java:751)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6119)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
@gpeal
Copy link
Collaborator

gpeal commented Nov 27, 2018

This will be fixed by #1002

@gpeal gpeal closed this as completed Nov 27, 2018
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