-
Notifications
You must be signed in to change notification settings - Fork 2.3k
App crashes when storage().putFile is called with assets-library uri on iOS #1232
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
Comments
I'm also seeing this. Going to start looking deeper now |
Could you check the logs within XCode, it should tell you exactly what happened to cause the crash? |
Also can confirm same code works on android, except for the standard fix of removing the extra bit of android path file:
|
The uri coming from React Native CameraRoll component (part of RN lib) looks like this:
And coming from react native camera kit (works) like this:
I'm going to try and keep investigating. Maybe that it is in the form of a query string not an absolute path? |
Ok so I tried a couple of things. First I tried both the promise style putfile and the putfile with progress and both crashed when trying to pass in the camer roll uri. I then tried this based off of @Salakar stack overflow post:
Which gives me an image path like this:
which doesn't crash it, but then it doesn't upload properly. It receives the progress callback, but then gets an 'unhandled error' in both the listener and promise style ways of structuring it (use ing either the err callback or the .catch) Edit, is it an issue that the application id is different in those two examples ^ between the one coming from the camera kit photo and the firebase native file path? |
Yes, app does not crash, but just hangs. I solved it by doing (in RNFirebaseStorage.m):
Hope it helps... |
@skbellevue I'll also try and confirm if it works thanks a lot. One question though is this in response to using the uri (which causes the hard crash) or the version where we append the filename to the native document patha nd then it never completes the upload properly and gets the uncaught error? |
Are you using a detached expo project? |
@SamMatthewsIsACommonName - Not sure I follow your question but this is in response of the screenshot you posted. I had the exact same issue while trying to upload a photo from the camera roll. |
Aah @skbellevue I see thanks. Dont worry I was being confusing! Can I ask what line this goes? I'm super unfamiliar with obj-c and dont want to break anything! |
Sorry ignore htat I found it! was looking in putfile vs uploadFIle... |
Ok working thanks! I'll make sure to keep patching it. So I put the conditional in both places basically. |
Apple changed the image format to HEIC in iOS 11. Not sure if that's related. Looks like your urls were JPGs but some of the other pickers out there (including Photos) translate HEIC to JPG whereas if you get an asset directly from the library it can be an HEIC and you need to use ALAssetLibrary to read it. |
@skbellevue thanks for the proposed solution, React has a util to do this, could you try importing RCTUtils and changing the dispatch as per the below (instead of the if statement in your example) - this will check if already on main thread. @skbellevue @SamMatthewsIsACommonName if either of you could try this that'd be great. Add the import: #import <React/RCTUtils.h> Diff - dispatch_sync(dispatch_get_main_queue(), ^{
+ RCTUnsafeExecuteOnMainQueueSync(^{ Upload task block after changes (no RCTUnsafeExecuteOnMainQueueSync(^{
uploadTask = [fileRef putFile:url metadata:firmetadata];
}); |
@Salakar will try today and report back ;) thanks |
@Salakar worked! |
@SamMatthewsIsACommonName nice 👌 thanks for testing, could you submit a patch/pr with the change if you could, can get it merged in for a future release. If not then I can pick this up in a few days. |
@Salakar well as crazy as this may seem because I am a 'one man band' I'm still amazingly unaware of how to do a pr.... I know its insane hahaha I need to learn one day |
@SamMatthewsIsACommonName no problem, thought I'd ask anyway =] leave it with me |
Thanks both for reporting this issue and helping me debug the issue with a proposed fix. I will close this issue for now and track it as well as other issues collectively over on the Storage improvements proposal to be addressed in a future release. See #1260 |
Fixed in #1195 - landing as part of v4.3.0 |
Fix is now live in the v4.3.0 release. Loving
|
Issue
I am trying to upload an image from the camera roll of the phone to Firebase Storage using react-native-firebase. However, when I pass the assets-library uri of the image to the putFile method, the app crashes without an error.
For example:
const uri = 'assets-library://asset/asset.JPG?id=3DEE5FA3-9E58-479B-9AD9-A7FDBEDF0502&ext=JPG'; firebase.storage().ref('test.jpeg').putFile(uri) .then(...) .catch(...);
Is this the expected behavior? If yes, I apologize for taking up your time. However, how can I transform the assets uri to a full file path that is recognized by RNFirebase?
Note: This is a repost of my question os Stack Overflow: https://stackoverflow.com/questions/50828924/app-crashes-when-storage-putfile-is-called-with-assets-library-uri-on-ios
Environment
Application Target Platform:
iOS, iPhone X simulator
Development Operating System:
macOS High Sierra 10.13.5
Build Tools:
Xcode: 9.4.1
React Native version:
0.55.4
RNFirebase Version:
https://github.com/invertase/react-native-firebase.git#build-issues
Firebase Module:
storage
The text was updated successfully, but these errors were encountered: