Skip to content
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 font variant crash on Android < 4.4 #29176

Closed
wants to merge 1 commit into from
Closed

Fix font variant crash on Android < 4.4 #29176

wants to merge 1 commit into from

Conversation

Almouro
Copy link
Contributor

@Almouro Almouro commented Jun 18, 2020

Summary

In RN 0.62 support for fontVariant was added on Android.
Using that prop crashes the app on Android below KitKat (4.3 and below)

To reproduce just add any Text with the fontVariant styling prop in the app:

<Text style={{fontVariant: ['tabular-nums']}}>This will crash</Text>

It will crash any device running Android below KitKat with the error:

image

This is caused by java.utils.Objects only being available on Android 4.4+

Changelog

[Android] [Fixed] - Fix font variant crash on Android < 4.4

Test Plan

TextUtils.equals was added as soon as API level 1, so no compatibility issue here.
Tested on Emulator running Android 4.1, no crash anymore.

I've searched for other occurences of java.utils.Objects in the project, and this was the only one, so no need to remove other occurences ✅

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 18, 2020
@react-native-bot react-native-bot added Bug Platform: Android Android applications. labels Jun 18, 2020
@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 6,764,089 -23
android hermes armeabi-v7a 6,426,896 7
android hermes x86 7,150,428 7
android hermes x86_64 7,040,345 -18
android jsc arm64-v8a 8,937,395 2
android jsc armeabi-v7a 8,592,558 -25
android jsc x86 8,766,818 -23
android jsc x86_64 9,342,392 -9

Base commit: e73208e

@analysis-bot
Copy link

analysis-bot commented Jun 18, 2020

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: a69bd9d

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdvacca has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@mdvacca mdvacca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good to me!

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @Almouro in f23fece.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Jul 2, 2020
grabbou pushed a commit that referenced this pull request Jul 14, 2020
Summary:
In RN 0.62 support for `fontVariant` was added on Android.
Using that prop crashes the app on Android below KitKat (4.3 and below)

To reproduce just add any Text with the `fontVariant` styling prop in the app:
```js
<Text style={{fontVariant: ['tabular-nums']}}>This will crash</Text>
```
It will crash any device running Android below KitKat with the error:

![image](https://user-images.githubusercontent.com/4534323/85073452-18206b80-b1bb-11ea-8d7e-96f27fa1a320.png)

This is caused by `java.utils.Objects` only being available on Android 4.4+

## Changelog

[Android] [Fixed] - Fix font variant crash on Android < 4.4
Pull Request resolved: #29176

Test Plan:
[TextUtils.equals](https://developer.android.com/reference/android/text/TextUtils#equals) was added as soon as API level 1, so no compatibility issue here.
Tested on Emulator running Android 4.1, no crash anymore.

I've searched for other occurences of `java.utils.Objects` in the project, and this was the only one, so no need to remove other occurences ✅

Reviewed By: JoshuaGross

Differential Revision: D22337316

Pulled By: mdvacca

fbshipit-source-id: 5507b21b237a725d596d47b5c01e269895b16d4a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Platform: Android Android applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants