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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when used offline first time #467

Closed
1 task done
FelixMittermeier opened this issue Sep 13, 2020 · 6 comments
Closed
1 task done

Crash when used offline first time #467

FelixMittermeier opened this issue Sep 13, 2020 · 6 comments

Comments

@FelixMittermeier
Copy link

馃悰 Bug Report

If you try to display a CachedNetworkImage which is not yet in the cache (e.g. at the very first start of the app) and the device is offline, you get repeated error messages like the following one:

SocketException (SocketException: Failed host lookup: '<my valid url>' (OS Error: No address associated with hostname, errno = 7))

The app freezes completely so there is nothing more you can do after this exception occurred.

Expected behavior

I would expect that nothing would happen and that the loading animation from the placeholder would simply continue spinning.

Reproduction steps

Create a simple app which just shows an image from a valid url. If the device is online at the first startup and offline at the next ones, everything is fine but if you're already offline at the first launch you get the error from above.

Configuration

Version: 1.4.2

Platform:

  • 馃 Android
@renefloor
Copy link
Collaborator

When I test it with a very simple example. I indeed get an info log like this:

I/flutter ( 3907): CacheManager: Failed to download file from http://via.placeholder.com/350x150 with error:
I/flutter ( 3907): SocketException: Failed host lookup: 'via.placeholder.com' (OS Error: No address associated with hostname, errno = 7)

However, my app doesn't freeze and the progress indicator just continues spinning.

If you have break on exceptions enabled the debugger stops, but that's because the dart VM doesn't always know whether an exception is caught or not. If you continue this still shouldn't freeze your app. Maybe something else is breaking the app?
image

@ranbeuer
Copy link

I'm writing an app where you can make cashouts from your account into your bank account and when you select the bank from a list, each of those banks' image is located somewhere in my servers, but some of them are not present. So, several requests are made to images that don't exist, which the log shows as following:

flutter: CacheManager: Failed to download file from http://media.upaga.mobi/logos/110x110/Zurichvi.png with error:
SocketException: Failed host lookup: 'media.upaga.mobi' (OS Error: nodename nor servname provided, or not known, errno = 8)

After a little while of entering and exiting the screen i get this on every web service call I make:

dnssd_clientstub deliver_request: socketpair failed 24 (Too many open files)

And the app's web service API stops working.

this is a piece of code where I'm using the CashedNetworkImage

DropdownButton<Institution>(
                    isExpanded: true,
                      value: banco,
                      icon: Icon(Icons.keyboard_arrow_down),
                      iconSize: 24,
                      underline: SizedBox(),
                      elevation: 16,
                      hint:
                      Container(
                          padding: EdgeInsets.all(10.0),
                          alignment: Alignment.centerLeft,
                          child: Text("Selecciona tu banco"),
                      ),
                      style: TextStyle(color: Colors.black54),
                      onChanged: (Institution newValue) {
                        setState(() {
                          banco = newValue;
                        });
                      },
                      items: bancos.map((Institution value) {
                        var imageUrl = value.getUrl();
                        return DropdownMenuItem<Institution>(
                            value: value,
                            child:Container(
                                padding: EdgeInsets.all(10.0),
                                height: 50,
                                child:Row(
                                    mainAxisSize: MainAxisSize.min,
                                    crossAxisAlignment: CrossAxisAlignment.center,
                                    mainAxisAlignment: MainAxisAlignment.center ,
                                    children:[
                                      CachedNetworkImage(
                                          placeholder: (context, url) => Image(image: AssetImage('assets/images/spei.png')),
                                          imageUrl: imageUrl,
                                      ),
                                      SizedBox(width: 10,),
                                      Text(value.name, style: TextStyle(fontFamily: 'Aspira',fontWeight: FontWeight.w200,fontSize:14),textAlign: TextAlign.left),
                                    ])
                            )

                        );
                      }).toList()
                  )

Hope you can help me solve this

@AliYar-Khan
Copy link

I am getting same error

`Failed host lookup: 'images.unsplash.com' (OS Error: No address associated with hostname, errno = 7)

`

When the exception was thrown, this was the stack: 
Image provider: CachedNetworkImageProvider("https://images.unsplash.com/39/lIZrwvbeRuuzqOoWJUEn_Photoaday_CSD%20(1%20of%201)-5.jpg?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80", scale: 1.0) 
 Image key: CachedNetworkImageProvider("https://images.unsplash.com/39/lIZrwvbeRuuzqOoWJUEn_Photoaday_CSD%20(1%20of%201)-5.jpg?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80", scale: 1.0): CachedNetworkImageProvider("https://images.unsplash.com/39/lIZrwvbeRuuzqOoWJUEn_Photoaday_CSD%20(1%20of%201)-5.jpg?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80", scale: 1.0)

I am stuck here !!!

@alexaung
Copy link

I have so many firebase crashlytics reported this issue but I can't reproduce on our test devices. I even use FadeInImage.memoryNetwork widget but more crash report come. May I know how do you solved this issue.

@wildsurfer
Copy link

Same issue :(

@darshsingh116
Copy link

Seems like the app is not crashing but only pausing as its an uncaught error.

i had the same issue with below code:

CachedNetworkImage(
placeholder: (context, url) => LoadingSkeleton(
width: double.infinity,
height: double.infinity,
colors: PurpleTheme.greyLoadingShadesColors,
),
errorWidget : (context, url, error) => LoadingSkeleton(
width: double.infinity,
height: double.infinity,
colors: PurpleTheme.greyLoadingShadesColors,
),
imageUrl: sellProductModel.imageUrl,
width: 300.w,
height: 150.h,
fit: BoxFit.cover,
)

TO FIX u should disable uncaughtError breakpoints like below and app works fine.
image

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

7 participants