Commit 64f3ca9
fix: get image info before creating drawable to avoid IllegalStateException (#2839)
Summary:
## Motivation
This PR aims to mitigate crash caused by `IllegalStateException` thrown due to closable image reference being already closed when getting the image info.
The crash is reported as #2826. On my end with version 3.6.0 I get following stack trace
```
java.lang.IllegalStateException: null
at com.facebook.common.internal.Preconditions.checkState(Preconditions.java:162)
at com.facebook.drawee.backends.pipeline.PipelineDraweeController.getImageInfo(PipelineDraweeController.java:366)
at com.facebook.drawee.backends.pipeline.PipelineDraweeController.getImageInfo(PipelineDraweeController.java:64)
at com.facebook.drawee.controller.AbstractDraweeController.reportSuccess(AbstractDraweeController.java:849)
at com.facebook.drawee.controller.AbstractDraweeController.onNewResultInternal(AbstractDraweeController.java:667)
at com.facebook.drawee.controller.AbstractDraweeController.-$$Nest$monNewResultInternal
at com.facebook.drawee.controller.AbstractDraweeController$2.onNewResultImpl(AbstractDraweeController.java:600)
at com.facebook.datasource.BaseDataSubscriber.onNewResult(BaseDataSubscriber.java:51)
at com.facebook.datasource.AbstractDataSource$1.run(AbstractDataSource.java:200)
at android.os.Handler.handleCallback(Handler.java:959)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loopOnce(Looper.java:257)
at android.os.Looper.loop(Looper.java:342)
at android.app.ActivityThread.main(ActivityThread.java:9634)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:619)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:929)
```
To mitigate the crash I moved reading image info before creating drawable from it and to be also surrounded by try-catch.
## Test Plan
Unfortunately I can't provide a test plan since the exception is thrown most likely due to some race condition.
Pull Request resolved: #2839
Reviewed By: defHLT
Differential Revision: D87565917
Pulled By: oprisnik
fbshipit-source-id: 4f6b09e88f0f660149eb8fbc9a57e784fdf9e14f1 parent 47aba6f commit 64f3ca9
1 file changed
Lines changed: 5 additions & 4 deletions
Lines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
647 | 647 | | |
648 | 648 | | |
649 | 649 | | |
| 650 | + | |
650 | 651 | | |
| 652 | + | |
651 | 653 | | |
652 | 654 | | |
653 | 655 | | |
| |||
665 | 667 | | |
666 | 668 | | |
667 | 669 | | |
668 | | - | |
| 670 | + | |
669 | 671 | | |
670 | 672 | | |
671 | 673 | | |
672 | | - | |
| 674 | + | |
673 | 675 | | |
674 | 676 | | |
675 | 677 | | |
| |||
846 | 848 | | |
847 | 849 | | |
848 | 850 | | |
849 | | - | |
850 | | - | |
| 851 | + | |
851 | 852 | | |
852 | 853 | | |
853 | 854 | | |
| |||
0 commit comments