-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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(android, utils): fix rare crash getting documents directory #5118
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/invertase/react-native-firebase/GuHm9FZ3bJhW76Q9L8k7QqNzb9pb |
|
Codecov Report
@@ Coverage Diff @@
## master #5118 +/- ##
=======================================
Coverage 88.99% 88.99%
=======================================
Files 109 109
Lines 3739 3739
Branches 358 358
=======================================
Hits 3327 3327
Misses 367 367
Partials 45 45 |
Hi @LittoCats ! I think this was already addressed in #4990 - when I look at the original diagnosis you did it seems correct but it's based on an old version of the code. In v11.1.0+ It already has a null check and so will not crash here |
Yes, I notice that last night, but I found, the constant value exported to js will be not exists for KEY_DOCUMENT_DIRECTORY when
|
That's true and I thought of that as I compared the two types of fix for the issue. Your fix will cause the directory to change between runs though, so the value will exist in your version but it won't be stable as external media is changed. I think that may just be an unsolvable problem though - maybe something just to put in the docs here vs attempt to solve in code The doc is here
|
Thanks for your explaination. |
Wait! @LittoCats I actually like this PR, I think the code itself is both correct and necessary to correct the null pointer exception - I am sorry I wasn't clear, what I think it needs is just an addition to the documentation as well as the code fix, to warn developers that this is an external directory which could change (making it appear as if documents appear or disappear) if the users external storage environment changes Hopefully that's more clear :-). I actually really want to get this fix in, you have solved a real crash! |
….SDK_INT >= Build.VERSION_CODES.KITKAT and externalDirectory != null
this ensures the documents directory always exists, at the expense of having it be a different value under rare circumstances (better than crashing at least...) Docs updated to reflect the rare cases it can return unexpected values
@LittoCats I had time today to look at this - I pulled your branch, fixed the compile error and then altered the documentation to explain the conditions when documents directory could be internal vs external. I think this should work and fix the crash - can you take a look? I can merge it and release it if it looks good |
…rtase#5118) * Fix: value for key KEY_DOCUMENT_DIRECTORY not exists if Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT and externalDirectory != null * fix(android, utils): fix rare crash getting documents directory this ensures the documents directory always exists, at the expense of having it be a different value under rare circumstances (better than crashing at least...) Docs updated to reflect the rare cases it can return unexpected values Co-authored-by: Mike Hardy <github@mikehardy.net>
NullPointerException Firebase Crashlytics
Description
The exported constant value for key KEY_DOCUMENT_DIRECTORY will be missed in ReactNativeFirebaseUtilsModule when Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT and externalDirectory == null
Related issues
Fixes #4706
Release Summary
Checklist
Android
iOS
e2e
tests added or updated inpackages/\*\*/e2e
jest
tests added or updated inpackages/\*\*/__tests__
Test Plan
Think
react-native-firebase
is great? Please consider supporting the project with any of the below:React Native Firebase
andInvertase
on Twitter