react-native
react-native copied to clipboard
Fix an infinite loop during getTypeface() due to a bug in HashMap.containsKey()
Summary
Our Crashlytics tool has been shown to have some crash issues on some devices running Android 4.4 (I cannot reproduce myself). It problems is from Line 59 of ReactFontManager.java. You can see the below image for better clarity.
Next, my understanding is that this StackOverflowError is due to a bug in containsKey() method of HashMap. The algorithm used within this method probably contains an unexpected bug. As a result, we have an infinite loop here.
Moreover, from the code, I notice that the variable "typeface" declared on line 60 is never checked null before the usage on the following lines. This shows that the value would not contain null. In this case, containsKey() would be redundant as the null value is not really possible here.
Eventually, by getting rid of containsKey(), we prevent this mysterious crash and benefit some speed up also.
Changelog
[Android] [Fixed] - Fix a crash due to a bug in containsKey causing an infinite loop in ReactFontManager.getTypeface()
Test Plan
I didn't have the devices with the crash myself. What I can do here is to see whether or not this same crash disappeared with the patched version.
Hi @thanakij!
Thank you for your pull request and welcome to our community.
Action Required
In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.
Process
In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.
Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed
. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.
If you have received this in error or have any questions, please contact us at [email protected]. Thanks!
Hi, I have just signed CLA. @facebook-github-bot
Platform | Engine | Arch | Size (bytes) | Diff |
---|---|---|---|---|
ios | - | universal | n/a | -- |
Base commit: 505f9fc74929326ea246eb4aeb700f97820c702f
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!
This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
@ghagevaibhav Any news on this?
This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This PR was closed because it has been stalled for 7 days with no activity.