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

Fixed Cannot clone a disposed image #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

YDA93
Copy link

@YDA93 YDA93 commented May 4, 2022

Because Image widget in buildBlurHashBackground does not have errorBuilder, its causing the framework to throw errors as per issues:

  1. Cannot clone a disposed image #46
  2. Bad state: Cannot clone a disposed image #40

Since buildBlurHashBackground is widget function instead of stateless widget this made it even harder to trace where the error is coming from.

Which was pointing to Flutter image widget only, which I think it should include buildBlurHashBackground too.

Please Refer to:

Stackoverflow

Flutter issue 19269

If you look at flutter image widget at image.dart line 1141:

assert(() {
  if (widget.errorBuilder == null) {
    // ignore: only_throw_errors, since we're just proxying the error.
    throw error; // Ensures the error message is printed to the console.
  }
  return true;
}());

Long story short:

Your code does not produce this error, our code does. Your code only does not enable us to handle it.

Kindly merge this.

Thanks,

@YDA93
Copy link
Author

YDA93 commented May 4, 2022

@Solido I would appreciate if you look into this for a minute.

@cpellet
Copy link

cpellet commented Jul 29, 2022

Kindly merge this please

@gauravmehta13
Copy link

this is a severe issue please check this

@andrewwakeling
Copy link

@YDA93 I tried your fork and I am still getting the same error.

Do you know if there's another way that the same error can appear, or do you know if there are still issues with your fix?

@YDA93
Copy link
Author

YDA93 commented Oct 5, 2022

@YDA93 I tried your fork and I am still getting the same error.

Do you know if there's another way that the same error can appear, or do you know if there are still issues with your fix?

Hi @andrewwakeling ,

You can replicate the issue following the steps:

  1. Create images in screen A.
  2. Navigate to screen B and Create the same images links from screen A.
  3. Clear images from memory on pop up.

I think this error happens when you clear images from memory while there still images displaying in other screens.

I stopped trying to fix this since most of it is none fatal errors.

I use extended image library to display images.

@Mayb3Nots
Copy link

Mayb3Nots commented Oct 12, 2022

@YDA93 I tried your fork and I am still getting the same error.

Do you know if there's another way that the same error can appear, or do you know if there are still issues with your fix?

Its possible your error is coming from a different source. See Baseflow/flutter_cached_network_image#746

@YDA93 how did you find out it was coming from this package or more specifically that function that is causing the issue? Because from my error logs I couldn't figure our where its coming from.

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

@YDA93
Copy link
Author

YDA93 commented Oct 13, 2022

@Mayb3Nots

As far as I remember I didn't have this error until i started using this package. I will do some re-tests today and will confirm if the issue comes from this package.

@andrewwakeling
Copy link

@Mayb3Nots

When I temporarily disable/remove blurhashes from my app, I'm no longer seeing the errors.

I can't say with 100% certainty that the fault comes from the blurhash library, but it does seem like the most likely culprit at this point.

@Mayb3Nots
Copy link

Mayb3Nots commented Oct 13, 2022

@Mayb3Nots

When I temporarily disable/remove blurhashes from my app, I'm no longer seeing the errors.

I can't say with 100% certainty that the fault comes from the blurhash library, but it does seem like the most likely culprit at this point.

I think we need to test with flutter 3.4.0 at this point to find out the real culprit.

Copy link

@felipecastrosales felipecastrosales left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR, I think this would be helps a lot.

@felipecastrosales
Copy link

I tried this alternative yesterday and today, but I still have the problem.

In my case, I have a widget tree that uses slivers widgets - and a relatively medium stack pages in app navigation; I believe it can make it appear more often.

So far, I haven't been able to fit into a fork I've made. Even though it's relatively "simple code", it seems to have a pretty big flow.

@bartekpacia
Copy link

bartekpacia commented Aug 4, 2023

TIL that cached_network_image depends on octo_image, which in turn depends on flutter_blurhash. So fixing this here, upstream, could maybe also fix cached_network_image#746?

@felipecastrosales
Copy link

I tried this again and this pr not fix the bad state problem, unfortunately.

@aarjan
Copy link

aarjan commented Oct 31, 2023

This issue occurs when i use the hash widget on top of cachedNetworkImage widget in a stack.
It doesn't occur if i use the hash as a placeholder widget.

@felipecastrosales
Copy link

@aarjan it also happens at this moment:

This issue occurs when i use the hash widget on top of cachedNetworkImage widget in a stack. It doesn't occur if i use the hash as a placeholder widget.

@senenpalanca97
Copy link

Same problem here!

@kienvtqhi
Copy link

Same problem! Any solution?

@kienvtqhi
Copy link

kienvtqhi commented Jan 10, 2024

Use BlurHashImage instead of. It worked for me

Before:
BlurHash(hash: userProfile.mainPhotoBlurhash)

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

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

Successfully merging this pull request may close these issues.

None yet