-
-
Notifications
You must be signed in to change notification settings - Fork 660
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
errorWidget: Not trapping HTTPException when scrolling in AnimatedList #536
Comments
Can you give me a small reproducable example of a crashing app? I would understand if the 403 exception is reported in the console or even any error reporting, but I've never seen an app crash. The problem is that the widget only attaches an errorListener while it is visible (otherwise the widget might not even exist or showing a different image). The ImageStreamCompleter checks if there is anybody listener, otherwise prints the error in the logs. You can see the relevant code here: https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/painting/image_stream.dart#L680 If you really have a crashing app that's indeed something we need to look into really quick, if you're just seeing it in the logs there is not much we can do about it other than convincing the Flutter team to change that part of the code. |
Thanks for the rapid response. I will see what I can do regarding an example but given I am reading from a database it will not be very representative of the real world situation. Regarding app crashes, I guess it depends on how you define a crash. This is what I see if I scroll slowly: and what I see if I scroll quickly (there is an error image under that dialogue, the dialogue comes from Catcher): Here is what I see in the debug console, whether or not the error dialogue has shown:
|
Ok, please see below an example app I have put together. It tries to access the same images (with invalid tokens) that my app does. I am also using ListView.builder rather than FirebaseAnimatedList. I am unable to reproduce the 'crash' that I experience with my app using Catcher and don't really want to build that in unless I have to. What you will see though is when scrolling slowly, the output to the debug console is various repetitions of as follows in blue text in the VSCode console):
However, if you scroll quickly you will see the above interspersed with the following messages (in white and red text):
These appear to be what causes 'crashes' (Catcher trapping) within my app. So I guess the question is, how to persuade my app's error trapping mechanism (Catcher) to ignore those exceptions? My Code
|
Ah, so it is not crashing, but Catcher catches it. I've never used Catcher, so I'm not 100% sure how it works, but having a quick look at it I might have found a problem with catcher. As you can see here: https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/painting/image_stream.dart#L665 an error can be reported as 'silent'. Image loading errors are reported as silent. Having a quick look at catcher I don't see them reading the 'silent' parameter from the ErrorDetails it receives here: https://github.com/jhomlala/catcher/blob/master/lib/core/catcher.dart#L385 |
That makes a lot of sense, Rene. Thanks. Having said above that I didn't want to, I was thinking of adding Catcher to my code example to see what happens. Think I will do that now and raise the issue with Jakub who is usually pretty responsive. Guess you can close this from your side. Thanks again. |
Thanks for your insight into this issue, Rene. As you see, I raised it with Jakub (of Catcher) and he has incorporated silent message handling as an option in the package config. It is all working well now. |
Hey @renefloor ! First of all thanks to you and your team for such a fantastic plugin! but I was thinking... Why not just wrap
within the "web_helper.dart" file in the "flutter_cache_manager" plugin That would eliminate the need for you too clarify, |
Because then you can't show an error widget. |
This link is an example with 403 status error maybe help |
Hey @renefloor, thanks for providing detailed feedback regarding the issue. I've been using this package for a while and despite this isolated scenario, it's excellent! As everyone on this thread, I've been experiencing this issue, and mostly in production apps receiving bad reviews due to declined performance and increased battery usage. What happens is, the CDN would return a placeholder image along with a 404 response status code. The package (or the underlying dependency) will eventually crash the app due to a continues loop or queue of some sort. This caused serious performance and user experience issues. My idea for bypassing the 404 or any other unsuccessful status code during the download cycle, came down to performing a The workaround was to go and strip out the package contents of Although this might not be the perfect solution, it's working quite well. |
Título del problema (Issue): Error al usar CachedNetworkImage en el paquete Flutter Cache Manager Descripción del problema: Al intentar utilizar CachedNetworkImage en mi aplicación Flutter, estoy experimentando un error relacionado con HttpExceptionWithStatus en el archivo web_helper.dart del paquete flutter_cache_manager. Esto está ocurriendo cuando intento mostrar una imagen desde una URL remota utilizando CachedNetworkImage con un placeholder y un errorWidget personalizados. Pasos para reproducir el problema:
Este es el Error que muestra por consola
/iconthrow' Información adicional:
|
🐛 Bug Report
Issue: #273 also refers but has been closed, yet the issue described is still present. I am experiencing exactly the same problems as described in this comment and the possible solutions suggested would seem to be realistic: #273 (comment)
I am using FirebaseAnimatedList in a chat app to display / add-to chat messages. These messages are a mix of text and images. I use CachedNetworkImage to handle the latter and it works very well, except when there are images in error AND I scroll quickly.
In my case the errors are HttpException: Invalid statusCode: 403 - permission denied - as I am trying to handle images on Cloud Storage that may not have a valid access token.
If I allow each image in error to show its error widget (in my case, a Text widget saying no image available) before scrolling it off the screen then all is well in the universe. If I quickly scroll the several images in error either up or down, thereby not giving CachedNetworkImage the chance to fully display the error widget then the app crashes (not just a console log in debug) and my Catcher implementation reports it but only from main.dart, not anywhere that I can usefully see a specific error in the code. The scrolling does not need to be very quick.
FYI, FirebaseAnimatedList is just an implementation of Dart's AnimatedList widget that builds based on a stream from a FB RTDB query. I would anticipate that this issue would also be the case even if I used a ListViewBuilder.
Expected behavior
I would expect the errorWidget: to fully trap the 403 (or what ever other error code) even if it has not completed displaying the error widget. However, it appears that it fails to do this or even propagates the error if it is still building the error widget. In either case I am unable to trap the error myself to handle the situation gracefully and stop the app crashing.
Reproduction steps
This is my code that uses CachedNetworkImage and is called from within my FirebaseAnimatedList.
Configuration
CachedNetworkImage: 2.5.0
flutter doctor -v
[√] Flutter (Channel stable, 1.22.5, on Microsoft Windows [Version 10.0.21292.1000], locale en-ZA)
• Flutter version 1.22.5 at C:\flutter
• Framework revision 7891006299 (5 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.
Platform:
Problem occurs on emulator and device.
The text was updated successfully, but these errors were encountered: