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

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

Open
1 of 2 tasks
raulmabe opened this issue May 24, 2022 · 13 comments
Open
1 of 2 tasks

Comments

@raulmabe
Copy link

raulmabe commented May 24, 2022

🔙 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
@hbock-42
Copy link

hbock-42 commented Jun 21, 2022

Same here, except I don't even need to pop a page.

The exception come from:
sky_engine->ui->painting.dart
From the method:

    if (_disposed) {
      throw StateError(
        'Cannot clone a disposed image.\n'
        '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.'
      );
    }
    assert(!_image._disposed);
    return Image._(_image);
  }

@raulmabe
Copy link
Author

raulmabe commented Aug 9, 2022

It happens only in iOS to me, I'll update the issue.

@himeshp
Copy link

himeshp commented Sep 19, 2022

Any update on this?
I can see it on both android and iOS.

@Mayb3Nots
Copy link

Mayb3Nots commented Oct 12, 2022

Hi I have this issue but I don't have cached_network_image as a dependency direct nor transitive so it might be possible its not from this package. But I do have a package that has report similar issue see fluttercommunity/flutter_blurhash#47

Edit: Found this flutter/flutter#110129. Issue is fixed but not yet in stable. Fix is in master

@alanlanglois
Copy link

alanlanglois commented Feb 28, 2023

Same here, I'm using bugsnag and it happens on both iOS and android.
I'm also having BlurHash used for certain images preload.

@Mayb3Nots
Copy link

Im pretty sure this is already fixed in the latest stable version of Flutter. Could you reproduce it with flutter 3.7.4?

@alanlanglois
Copy link

I got it in production using Flutter 3.7.7

@bartekpacia
Copy link

My app uses the (currently) latest Flutter 3.10.6, and I'm also experiencing this error after I go to home and then go back to the app. iPhone 12 mini, iOS 16.

@nicklbaert
Copy link

nicklbaert commented Nov 6, 2023

My app uses the (currently) latest Flutter 3.10.6, and I'm also experiencing this error after I go to home and then go back to the app. iPhone 12 mini, iOS 16.

@bartekpacia Did you by any chance find a solution?

@bartekpacia
Copy link

Nope, there's no solution. This package has a bug that has to be fixed.

@senenpalanca97
Copy link

senenpalanca97 commented Nov 7, 2023

Same problem here. Have been using this library for a long time without problems but now I've received in sentry a lot of events for this bug.
EDIT: I'm using cached_network_image & blurhash.

@kienvtqhi
Copy link

Same problem here. Have been using this library for a long time without problems but now I've received in sentry a lot of events for this bug. EDIT: I'm using cached_network_image & blurhash.

Use BlurHashImage instead of. It worked for me

Before:
BlurHash(hash: userProfile.mainPhotoBlurhash)

After:
Image( image: BlurHashImage(userProfile.mainPhotoBlurhash), fit: BoxFit.cover, )

@JavierPerezLavadie
Copy link

Hello I have the same problem with flutter 3.16.8, it happened since the last update of the package with octo set and the extensions

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

No branches or pull requests

10 participants