In firebase crashlytic, i constantly receive two types of crash exception from this package cache_network_image. Below are the exception
1: ImageLoader.loadImageAsync.<fn> io.flutter.plugins.firebase.crashlytics.FlutterError - Exception: Invalid image data. Error thrown resolving an image codec.
2: ImageLoader.loadBufferAsync.<fn> io.flutter.plugins.firebase.crashlytics.FlutterError - Exception: Invalid image data. Error thrown resolving an image codec.
Stacktrace
(1.)
Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError
Exception: Invalid image data. Error thrown resolving an image codec..instantiateImageCodecWithSize (dart:ui)
ImageLoader.loadImageAsync.<fn> (_image_loader.dart:68)
ImageLoader._load (_image_loader.dart:129)
new MultiImageStreamCompleter.<fn> (multi_image_stream_completer.dart:26)
(2.)
Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError
Exception: Invalid image data. Error thrown resolving an image codec..instantiateImageCodecWithSize (dart:ui)
ImageLoader.loadBufferAsync.<fn> (_image_loader.dart:68)
ImageLoader._load (_image_loader.dart:129)
new MultiImageStreamCompleter.<fn> (multi_image_stream_completer.dart:26)
Keys:
flutter_error_exception Exception: Invalid image data
flutter_error_reason thrown resolving an image codec
Below is the code I use
CachedNetworkImage(
width: ScreenHelper().getScreenWidth(0.35),
height: ScreenHelper().getScreenHeight(0.18),
progressIndicatorBuilder: (context, url, progress) =>
SkeletonContainer.square(
width: ScreenHelper().getScreenWidth(0.35),
height: ScreenHelper().getScreenHeight(0.18),
borderRadius: const BorderRadius.all(Radius.circular(10)),
),
fit: BoxFit.fill,
imageUrl: imgUrl,
errorWidget: (context, url, error) => Image.asset(
AppAsset.appLogo,
gaplessPlayback: true,
fit: BoxFit.contain,
),
),
My question is, does this exception is common for this package? the crash event counts keep stacking and exceed thousands. But errorWidget
is used to handle what to render if image failed loading right? Why the exception still constantly trigger. Or I actually didn't handle this package correctly?
Ran into this issue myself these last few months. The issue is with the CachedNetworkImage library. Try to handle it by updating the crashlytics error recorder to ignore it
For more information see https://github.com/Baseflow/flutter_cached_network_image/issues/336#issuecomment-1693519544