flutter_blurhash icon indicating copy to clipboard operation
flutter_blurhash copied to clipboard

Fixed Cannot clone a disposed image

Open YDA93 opened this issue 3 years ago • 18 comments

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

  1. https://github.com/fluttercommunity/flutter_blurhash/issues/46
  2. https://github.com/fluttercommunity/flutter_blurhash/issues/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 avatar May 04 '22 21:05 YDA93

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

YDA93 avatar May 04 '22 21:05 YDA93

Kindly merge this please

cpellet avatar Jul 29 '22 13:07 cpellet

this is a severe issue please check this

gauravmehta13 avatar Sep 24 '22 08:09 gauravmehta13

@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?

andrewwakeling avatar Oct 04 '22 03:10 andrewwakeling

@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.

YDA93 avatar Oct 05 '22 13:10 YDA93

@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 https://github.com/Baseflow/flutter_cached_network_image/issues/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 https://github.com/flutter/flutter/issues/110129. Issue is fixed but not yet in stable (3.3.4). Fix is in master

Mayb3Nots avatar Oct 12 '22 18:10 Mayb3Nots

@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.

YDA93 avatar Oct 13 '22 05:10 YDA93

@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.

andrewwakeling avatar Oct 13 '22 07:10 andrewwakeling

@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.

Mayb3Nots avatar Oct 13 '22 14:10 Mayb3Nots

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.

felipecastrosales avatar Jul 11 '23 13:07 felipecastrosales

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?

bartekpacia avatar Aug 04 '23 14:08 bartekpacia

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

felipecastrosales avatar Sep 01 '23 12:09 felipecastrosales

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.

aarjan avatar Oct 31 '23 05:10 aarjan

@aarjan it also happens at this moment:

  • https://github.com/fluttercommunity/flutter_blurhash/issues/40#issuecomment-1769673892

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 avatar Oct 31 '23 12:10 felipecastrosales

Same problem here!

senenpalanca97 avatar Nov 07 '23 11:11 senenpalanca97

Same problem! Any solution?

kienvtqhi avatar Jan 06 '24 08:01 kienvtqhi

Use BlurHashImage instead of. It worked for me

Before: BlurHash(hash: userProfile.mainPhotoBlurhash)

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

kienvtqhi avatar Jan 10 '24 09:01 kienvtqhi