fluttercommunity / flutter_blurhash

Compact representation of a placeholder for an image. Encode a blurry image under 30 caracters for instant display like used by Medium. Maintainer: @Solido
https://pub.dev/packages/flutter_blurhash
MIT License
513 stars 65 forks source link

Fixed Cannot clone a disposed image #47

Open YDA93 opened 2 years ago

YDA93 commented 2 years ago

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 commented 2 years ago

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

cpellet commented 1 year ago

Kindly merge this please

gauravmehta13 commented 1 year ago

this is a severe issue please check this

andrewwakeling commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

@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

YDA93 commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

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

felipecastrosales commented 1 year ago

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 commented 11 months ago

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 commented 10 months ago

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

aarjan commented 9 months ago

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 commented 8 months ago

@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 commented 8 months ago

Same problem here!

kienvtqhi commented 6 months ago

Same problem! Any solution?

kienvtqhi commented 6 months ago

Use BlurHashImage instead of. It worked for me

Before: BlurHash(hash: userProfile.mainPhotoBlurhash)

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