[0.75.2] Blob not found
"sometimes" when accessing a content URI subsequent times
#47709
Labels
Needs: Author Feedback
Needs: Repro
This issue could be improved with a clear list of steps to reproduce the issue.
Newer Patch Available
Description
Hello,
we are currently facing an issue when working with blobs in our application. We organize attachments in our application with blob/content uris. The general flow is as follows:
XMLHttpRequest
to fetch a binary from our backendURL.createObjectURL
to create a content uri to the attachment (e.g.content://com.gaia.blob/d7809c88-a0e7-4fe6-b049-68d9154d8794?offset=0&size=59301
)Image
component)Due to the architecture of our application, we never use external URLs for attachments (like
https://path/to/image.png
). Our client accesses a known URL for an attachment (likehttps://path/to/attachment/<id>
(usingXMLHttpRequest
explained above), which will return the binary directly, we create a content uri for it and manage it using said url. This works very well for the web version of our application (which usesreact
, notreact-native
), but in RN, we're facing some issues.The procedure described above works without a problem on RN, we get a content uri and can feed it to a component to display it, no problem. In some scenarios, we need to access the content uri again after we have already displayed it (meaning fed it to e.g.
Image
), for example for various actions regarding the attachment (Download
, which just copies the attachment to the downloads folder,Open with
,Share
and so on).At some point after initially displaying the attachment and trying to access the content uri again, the binary data of the attachment is gone. It reports
[13:22:21.245Z][Console] [java.io.FileNotFoundException: Cannot open content://com.gaia.blob/d7809c88-a0e7-4fe6-b049-68d9154d8794?offset=0&size=59301, blob not found.]
The difficult part is that we don't know what we do inbetween that breaks things. The user may click on a button, which renders a view, or a bottom sheet or something else, goes to another screen, comes back, tries to open the previously displayed attachment using their default application, and it's broken.
To add to this, it doesn't happen every time. We have been unable to set up a scenario that reproduces this bug consistently. Sometimes accessing the attachment after the user opened a bottom sheet (note: This bug isn't related to us opening a bottom sheet, we have the same problem everywhere we interact with attachments, this is just an example) and closed it again will work for 2, 3 times, and then it breaks, sometimes it breaks right away.
I'm sorry I'm being vague here and can't describe the issue any further, but we simply don't know what we're doing between invoking
createObjectURL
and the error mentioned above. Unfortunately the project is closed source so I can not provide a working example to test this.In the web version of our application, we use
revokeObjectURL
(at a point when we are sure we don't need the binary anymore). However, due torevokeObjectURL
not being implemented in RN, we obviously don't do this here.My gut tells me, that the binary is getting garbage collected. After looking through the RN's code base, I noticed that the
close
function in react-native/Libraries/Blob/Blob.js:135 does exactly that. However I added a log entry to it and verified that it's never getting called throughout this process.What we sometimes see in log cat are warnings like
2024-11-19 13:58:32.739 12664-12672 System com.gaia W A resource failed to call close.
Although we're not sure whether or not they are related.
Again, I'm sorry to not be able to provide further information. I'd be happy to give additional feedback if needed. If individual pieces of code are needed, I may be able to provide them, unfortunately, due to the project not being public, I can't provide a reproducible example. I guess to have some foundation for a discussion:
Again, we're not even sure GC is the problem here, but it's the only thing we can think of as of now.
We are currently running
0.75.2
, due to some dependencies, we're currently unable to update to a later version. It's also unknown for how long this problem has existed, we first noticed it two weeks ago.Steps to reproduce
See above
React Native Version
0.75.2
Affected Platforms
Runtime - Android, Runtime - iOS
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/react-native-community/reproducer-react-native
Screenshots and Videos
No response
The text was updated successfully, but these errors were encountered: