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

Image onError logs undefined on Android #19073

Closed
3 tasks done
connorwaslo opened this issue Apr 30, 2018 · 12 comments
Closed
3 tasks done

Image onError logs undefined on Android #19073

connorwaslo opened this issue Apr 30, 2018 · 12 comments
Labels
Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.

Comments

@connorwaslo
Copy link

connorwaslo commented Apr 30, 2018

Environment

OS: Windows 10
Node: 8.2.1
Yarn: 1.3.2
npm: 5.8.0
Watchman: Not Found
Xcode: N/A
Android Studio: Version 3.1.0.0 AI-173.4670197

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.0 => 0.55.0

Steps to Reproduce

<ImageBackground style={{ flex: 1 }}
                             resizeMode='stretch'
                             onError={({ nativeEvent: {error} }) => console.log('Error:', error) }
                             source={require('../../res/images/img.png')}>
    {/* Children */}
</ImageBackground>

Expected Behavior

Logging error variable should print the reason that the Image is not being loaded.

Actual Behavior

error is undefined.

@react-native-bot
Copy link
Collaborator

Thanks for posting this! It looks like your issue may be missing some necessary information. Can you run react-native info and edit your issue to include these results under the Environment section?

Thank you for your contributions.

@maxhawkins
Copy link

maxhawkins commented May 14, 2018

I am also experiencing this issue.

react: 16.3.1 => 16.3.1
react-native: 0.55.3 => 0.55.3

My steps to reproduce are a little simpler.

<Image
  onError={ ({ nativeEvent: {error} }) => console.warn(error) }
  source={{ uri: imageUrl }} />

imageUrl is a path in the application cache directory. It points to an image from the camera that was processed by an image crop tool.

I verified that the image exists at imageUrl using RNFetchBlob.fs.stat. I pulled the image to my computer and was able to open it.

I expected an error to be passed to onError. Instead, error is undefined.

@maxhawkins
Copy link

I fixed my issue. I needed to prepend the path with file:// on Android.

Frustrating no error is passed to onError on Android!

@tad-lispy
Copy link

I am also affected by this. In my case I am loading many (thousands) images in a FlatList. On Android some of them are not loaded and onError callback is being called, but the argument to it doesn't seem to contain any useful information (just as OP described error.nativeEvent.error === undefined. So I'm left to trial and error and guesswork to understand the reason.

Perhaps it's related to #7440

For reference, also reported here: https://stackoverflow.com/questions/49136720/react-native-image-how-to-use-onerror#comment85402686_49137662

In my particular case I suspect it's some kind of memory or other resource related problem, as same images are loaded if I limit the total number of images. IOS doesn't seem to be affected, perhaps due to a better performance.

@edo1493
Copy link
Contributor

edo1493 commented Aug 15, 2018

Same

@vitorebatista
Copy link

Same here...

@FibreFoX
Copy link

This got already posted but closed as resolved, which is wrong:
#7440

I got in the same situation and found that old issue. Using the workaround by using https://www.npmjs.com/package/react-native-android-image-polyfill helped a bit, but this should be done inside RN-core itself IMHO.

@Jyrno42
Copy link
Contributor

Jyrno42 commented Aug 29, 2018

Same issue here, but I cannot use the workaround due to Image.prefetch having no support for headers :(

Would love to work on this if I could just figure out where to start...

@stale
Copy link

stale bot commented Nov 27, 2018

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Nov 27, 2018
@Jyrno42
Copy link
Contributor

Jyrno42 commented Nov 27, 2018

not stale

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Nov 27, 2018
@FibreFoX
Copy link

FibreFoX commented Dec 4, 2018

As far as I can tell, this issue contains the same as #18502 ... which one should stay open?! Or are they different?

@niuniubuniu
Copy link

@react-native-bot Image onError logs undefined on Android

Jyrno42 added a commit to Jyrno42/react-native that referenced this issue Dec 20, 2018
Verified on CircleCI via integration tests.

[ANDROID] [BUGFIX] [Image] - Add error description to onError callback

fixes facebook#19073
Jyrno42 added a commit to Jyrno42/react-native that referenced this issue Dec 20, 2018
**Test Plan**: Verified on CircleCI via integration tests.

**Changelog:**

[ANDROID] [BUGFIX] [Image] - Add error description to onError callback

fixes facebook#19073
Jyrno42 added a commit to Jyrno42/react-native that referenced this issue Dec 20, 2018
**Test Plan**: Verified on CircleCI via integration tests.

**Changelog:**

[ANDROID][BUGFIX][Image] - Add error description to onError callback

fixes facebook#19073
Jyrno42 added a commit to Jyrno42/react-native that referenced this issue Dec 20, 2018
**Test Plan**: Verified on CircleCI via integration tests.

**Changelog:**

[ANDROID][BUGFIX][Image] - Add error description to onError callback

fixes facebook#19073
Jyrno42 added a commit to Jyrno42/react-native that referenced this issue Dec 21, 2018
**Test Plan**: Verified on CircleCI via integration tests.

**Changelog:**

[ANDROID][BUGFIX][Image] - Add error description to onError callback

fixes facebook#19073
grabbou pushed a commit that referenced this issue Feb 4, 2019
Summary:
fixes #19073

Changelog:
----------

[Android] [Fixed] - Add error description to Image onError callback
Pull Request resolved: #22737

Differential Revision: D13676224

Pulled By: hramos

fbshipit-source-id: 0dea7e97ae6517b8980ad02827f19d22cd3ef933
matt-oakes pushed a commit to matt-oakes/react-native that referenced this issue Feb 7, 2019
)

Summary:
fixes facebook#19073

Changelog:
----------

[Android] [Fixed] - Add error description to Image onError callback
Pull Request resolved: facebook#22737

Differential Revision: D13676224

Pulled By: hramos

fbshipit-source-id: 0dea7e97ae6517b8980ad02827f19d22cd3ef933
t-nanava pushed a commit to microsoft/react-native-macos that referenced this issue Jun 17, 2019
)

Summary:
fixes facebook#19073

Changelog:
----------

[Android] [Fixed] - Add error description to Image onError callback
Pull Request resolved: facebook#22737

Differential Revision: D13676224

Pulled By: hramos

fbshipit-source-id: 0dea7e97ae6517b8980ad02827f19d22cd3ef933
@facebook facebook locked as resolved and limited conversation to collaborators Jan 25, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jan 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants