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

[BUG][QUESTION] Unexpected error trapping by Catcher when using cached_network_image #136

Closed
GrahamDi opened this issue Jan 22, 2021 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@GrahamDi
Copy link

GrahamDi commented Jan 22, 2021

Problem Description (not sure this is a bug)
catcher: ^0.4.0

I am using the cached_network_image package to cache and display chat message images returned in a FirebaseAnimatedList in my mobile app.

CachedNetworkImage provides for an error widget to be displayed when the requested image cannot be found/accessed for whatever reason. In my case, I am testing the access token to the image on Cloud Storage and return code is -403 permission denied when the access token is invalid.

When I scroll the list of message images slowly, all is well ie. the error widget is displayed and Catcher does not trigger because the -403 error has been 'absorbed' by the CachedNetworkImage errorWidget: process. However, when I scroll quickly (normally) and therefore don't give the error widgets time to fully display, I get error(s) caught by Catcher. I cannot track down where Catcher is trapping these, they have no stack trace and appear to be triggered in main.dart, which has no explicite try / catch or .catchError statements.

I assumed this was a bug in cached_network_image and I raised this issue: Baseflow/flutter_cached_network_image#536

I attached some sample code there to try and replicate the issue and it shows a specific message when scrolling quickly, which does not appear when scrolling slowly.

Rene Floor, of BaseFlow, investigated and confirmed that it is not an issue with cached_network_image but has a theory of why Catcher is trapping these. Please see this specific comment: Baseflow/flutter_cached_network_image#536 (comment)

The BaseFlow issue is now closed but I would appreciate it if you would read my description of the issue there and perhaps try the code. I would then like your view on what I am experiencing and if there is some way I can stop Catcher trapping this when scrolling quickly.

Many thanks.

To Reproduce
Please see details and sample code in the above mentioned issue.

Expected behavior
I would have expected the -403 error not to propagate from CachedNetworkImage and hence not be caught by Catcher or, if the silent exception for images is correct, for Catcher to ignore it.

Screenshots
Please see screenshots in above mentioned issue.

Flutter doctor
flutter doctor -v
[√] Flutter (Channel stable, 1.22.5, on Microsoft Windows [Version 10.0.21292.1010], locale en-ZA)
• Flutter version 1.22.5 at C:\flutter
• Framework revision 7891006299 (6 weeks ago), 2020-12-10 11:54:40 -0800
• Engine revision ae90085a84
• Dart version 2.10.4

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at D:\Android
• Platform android-30, build-tools 30.0.3
• ANDROID_HOME = D:\Android
• ANDROID_SDK_ROOT = D:\Android
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.

[!] Android Studio (version 4.1.0)
• Android Studio at C:\Program Files\Android\Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] VS Code (version 1.52.1)
• VS Code at C:\Users\dicki\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.18.1

[√] Connected device (1 available)
• AOSP on IA Emulator (mobile) • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

! Doctor found issues in 1 category.
Catcher version

  • Version:

Smartphone (please complete the following information):
Occurs on emulator and Hauwei P Smart device. Android 9 but issue is not Android version dependent.

@GrahamDi GrahamDi added the New issue New issue which has not been checked yet label Jan 22, 2021
@jhomlala
Copy link
Owner

jhomlala commented Feb 7, 2021

@GrahamDi in 0.4.1 I've added new parameter in CatcherOptions: handleSilentError. Set this as false and Catcher will ignore silent errors.

Also you can use explicit handler and report modes to handle specific error with different behavior.

@jhomlala jhomlala added enhancement New feature or request and removed New issue New issue which has not been checked yet labels Feb 7, 2021
@GrahamDi
Copy link
Author

GrahamDi commented Feb 7, 2021

Great stuff. Thanks very much, Jakub.

@GrahamDi
Copy link
Author

Finally got around to testing this (was working on another project) and it works perfectly. Thanks again. Closing the issue now.

@Nazarii77
Copy link

Wooow that what I was looking for! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants