-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Fix iOS unchanged local assets refetched from packager in development #9795
Fix iOS unchanged local assets refetched from packager in development #9795
Conversation
By analyzing the blame information on this pull request, we identified @davidaurelio and @frantic to be potential reviewers. |
Also see my comment #9581 (comment) which explains what caused the issue. |
@jeanregisser I agree #9581 is a pretty important issue - in production images should be cached and not always refetched. Why not always refetch them from the packager during development though? With the change in this PR, what if I update the logo.png in the filesystem and Reload JS? The app should render the new logo immediately. Will it? |
I think it's unexpected to always refetch the same local assets in development mode. For instance, if you have a screen showing 10 local images, the first time it's displayed, they are going to be fetched from the packager and this is normal and expected. Up until RN < 0.31.0 local images were just fetched once (unless you changed them). The PR restores this behavior on iOS. And if you change logo.png and reload, you'll see the new logo as expected. |
@mkonicek what do you think of my answer? |
Thanks for repairing this! |
@facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to Phabricator to review internal test results. |
@jeanregisser there are a couple of tests failing. Could you fix or adapt them, please? |
Yes. I'll have a look. |
I tried to merge this pull request into the Facebook internal repo but some checks failed. To unblock yourself please check the following: Does this pull request pass all open source tests on GitHub? If not please fix those. Does the code still apply cleanly on top of GitHub master? If not can please rebase. In all other cases this means some internal test failed, for example a part of a fb app won't work with this pull request. I've added the Import Failed label to this pull request so it is easy for someone at fb to find the pull request and check what failed. If you don't see anyone comment in a few days feel free to comment mentioning one of the core contributors to the project so they get a notification. |
data => res.end(this._rangeRequestMiddleware(req, res, data, assetPath)), | ||
data => { | ||
// Tell clients to cache this for 1 year. | ||
// This is safe as the asset url contains a hash of the mtime of the asset. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this say hash of the asset files instead of mtime now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated thanks.
c0ba6c8
to
f272ff2
Compare
@jeanregisser updated the pull request - view changes - changes since last import |
1a3e6eb
Summary: Hi, This PR fixes the problem described by chrisnojima in facebook/react-native#9581 (comment) **Test plan** In development mode, - Run an app with an image: `<Image source={ require('./logo.png') }/>` - Notice that you see the following in packager console: ```txt 6:46:42 PM] <START> processing asset request logo.png [6:46:42 PM] <END> processing asset request logo.png (1ms) ``` - Reload the app, or navigate to another page of the app with the same image - Notice that you see again: ```txt 6:47:23 PM] <START> processing asset request logo.png [6:47:23 PM] <END> processing asset request logo.png (1ms) ``` Now wih the fix applied, notice that you only see `logo.png` fetched once, even if you reload or show the same image in a different part of the app. Let me know what you think. Closes facebook/react-native#9795 Differential Revision: D3876945 Pulled By: davidaurelio fbshipit-source-id: f41f4719e87644692a690123fd6e54eead9cc87d
Hi,
This PR fixes the problem described by @chrisnojima in #9581 (comment)
Test plan
In development mode,
<Image source={ require('./logo.png') }/>
Now wih the fix applied,
notice that you only see
logo.png
fetched once, even if you reload or show the same image in a different part of the app.Let me know what you think.