Skip to content

StateError: Bad state: Cannot clone a disposed image after app changes lifecycle #746

@raulmabe

Description

@raulmabe

🔙 Regression

Hi, I have received 300 events in 14 days in Sentry that some users are getting an error related with images and I think this package may have to do with it (as I do not manipulate images directly, nor another package that I have... Also the issue may be related to #513.).

I am getting these two errors after app lifecycles changes.

StateError: Bad state: Cannot clone a disposed image.
The clone() method of a previously-disposed Image was called. Once an Image object has been disposed, it can no longer be used to create handles, as the underlying data may have been released.
  File "painting.dart", line 1815, in Image.clone
  File "image_stream.dart", line 50, in ImageInfo.clone
  File "image_stream.dart", line 645, in ImageStreamCompleter.setImage
  File "zone.dart", line 1434, in _rootRunUnary
String: Bad state: Cannot clone a disposed image.
The clone() method of a previously-disposed Image was called. Once an Image object has been disposed, it can no longer be used to create handles, as the underlying data may have been released.
  File "painting.dart", line 1815, in Image.clone
  File "image_stream.dart", line 50, in ImageInfo.clone
  File "image_stream.dart", line 645, in ImageStreamCompleter.setImage
  File "zone.dart", line 1434, in _rootRunUnary

Reproduction steps

I have the following breadcrumbs (may be incomplete, but will provide more info as I get):

  1. Move the app to the background
  2. Resume the app

Configuration

flutter doctor -v
flutter doctor -v
[✓] Flutter (Channel stable, 3.0.0, on macOS 11.6 20G165 darwin-x64, locale es-ES)
    • Flutter version 3.0.0 at /Users/raulmateobeneyto/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ee4e09cce0 (2 weeks ago), 2022-05-09 16:45:18 -0700
    • Engine revision d1b9a6938a
    • Dart version 2.17.0
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/raulmateobeneyto/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] VS Code (version 1.67.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.40.0

[✓] Connected device (4 available)
    • ONEPLUS A6013 (mobile) • fe0fb3b5                             • android-arm64  • Android 11 (API 30)
    • iPhone 13 Pro (mobile) • D32273CD-17B7-4F4D-AA28-AF043DEB3851 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
    • macOS (desktop)        • macos                                • darwin-x64     • macOS 11.6 20G165 darwin-x64
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 101.0.4951.64

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Plugin version: cached_network_image: ^3.2.1

Platform:

  • 📱 iOS
  • 🤖 Android

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions