forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 135
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
Workaround to open file handles for loaded assets #1287
Merged
Saadnajmi
merged 1 commit into
microsoft:main
from
christophpurrer:workaroundToOpenFileHandlesForLoadedAssets
Sep 22, 2022
Merged
Workaround to open file handles for loaded assets #1287
Saadnajmi
merged 1 commit into
microsoft:main
from
christophpurrer:workaroundToOpenFileHandlesForLoadedAssets
Sep 22, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
christophpurrer
force-pushed
the
workaroundToOpenFileHandlesForLoadedAssets
branch
from
July 25, 2022 17:10
6699f98
to
32d862d
Compare
harrieshin
reviewed
Jul 25, 2022
christophpurrer
changed the title
Workaround to open file handles for loaded assets
Workaround to open file handles for loaded assets [RFC]
Aug 2, 2022
christophpurrer
changed the title
Workaround to open file handles for loaded assets [RFC]
[RFC] Workaround to open file handles for loaded assets
Aug 10, 2022
christophpurrer
changed the title
[RFC] Workaround to open file handles for loaded assets
Workaround to open file handles for loaded assets
Aug 13, 2022
christophpurrer
force-pushed
the
workaroundToOpenFileHandlesForLoadedAssets
branch
from
September 9, 2022 21:20
32d862d
to
11e5723
Compare
We ran into an issue that our production app was crashing on certain devices as we opened too many file descriptors (> 256). See some details here: https://wilsonmar.github.io/maximum-limits/ We found that macOS will keep image files handles open for `NSImage` lifetime in some cases: ``` // this will keep file open only if image is loaded from app bundle NSString *path = [[NSBundle mainBundle] pathForResource:@"slider" ofType:@"png" inDirectory:@"assets"]; _image = [[NSImage alloc] initWithContentsOfFile:path]; // this will not keep file open _image = [[NSImage alloc] initWithContentsOfFile:@"/Users/theUser/Downloads/slider.png"]; // this will not keep file open NSData *data = [NSData dataWithContentsOfFile:path]; _image = [[NSImage alloc] initWithData:data]; ``` This can be documented behavior, but I didn't find any reference in documentation or headers. Test Plan: - build and run prod version of app - explore open files for Messenger process in Activity Monitor - confirm no assets are open
christophpurrer
force-pushed
the
workaroundToOpenFileHandlesForLoadedAssets
branch
from
September 21, 2022 18:55
11e5723
to
d5d8e51
Compare
Saadnajmi
approved these changes
Sep 22, 2022
shwanton
pushed a commit
to shwanton/react-native-macos
that referenced
this pull request
Feb 13, 2023
We ran into an issue that our production app was crashing on certain devices as we opened too many file descriptors (> 256). See some details here: https://wilsonmar.github.io/maximum-limits/ We found that macOS will keep image files handles open for `NSImage` lifetime in some cases: ``` // this will keep file open only if image is loaded from app bundle NSString *path = [[NSBundle mainBundle] pathForResource:@"slider" ofType:@"png" inDirectory:@"assets"]; _image = [[NSImage alloc] initWithContentsOfFile:path]; // this will not keep file open _image = [[NSImage alloc] initWithContentsOfFile:@"/Users/theUser/Downloads/slider.png"]; // this will not keep file open NSData *data = [NSData dataWithContentsOfFile:path]; _image = [[NSImage alloc] initWithData:data]; ``` This can be documented behavior, but I didn't find any reference in documentation or headers. Test Plan: - build and run prod version of app - explore open files for Messenger process in Activity Monitor - confirm no assets are open Co-authored-by: Scott Kyle <skyle@fb.com>
shwanton
pushed a commit
to shwanton/react-native-macos
that referenced
this pull request
Mar 10, 2023
We ran into an issue that our production app was crashing on certain devices as we opened too many file descriptors (> 256). See some details here: https://wilsonmar.github.io/maximum-limits/ We found that macOS will keep image files handles open for `NSImage` lifetime in some cases: ``` // this will keep file open only if image is loaded from app bundle NSString *path = [[NSBundle mainBundle] pathForResource:@"slider" ofType:@"png" inDirectory:@"assets"]; _image = [[NSImage alloc] initWithContentsOfFile:path]; // this will not keep file open _image = [[NSImage alloc] initWithContentsOfFile:@"/Users/theUser/Downloads/slider.png"]; // this will not keep file open NSData *data = [NSData dataWithContentsOfFile:path]; _image = [[NSImage alloc] initWithData:data]; ``` This can be documented behavior, but I didn't find any reference in documentation or headers. Test Plan: - build and run prod version of app - explore open files for Messenger process in Activity Monitor - confirm no assets are open Co-authored-by: Scott Kyle <skyle@fb.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please select one of the following
Summary
We ran into an issue that our production app was crashing on certain devices as we opened too many file descriptors (> 256). See some details here: https://wilsonmar.github.io/maximum-limits/
We found that macOS will keep image files handles open for
NSImage
lifetime in some cases:This can be documented behavior, but I didn't find any reference in documentation or headers.
Changelog
[macOS] [Fixed] - Workaround to open file handles for loaded assets
Test Plan