Skip to content

Reduce use of Java exceptions in prop parsing#36160

Closed
motiz88 wants to merge 1 commit into
facebook:mainfrom
motiz88:export-D43274525
Closed

Reduce use of Java exceptions in prop parsing#36160
motiz88 wants to merge 1 commit into
facebook:mainfrom
motiz88:export-D43274525

Conversation

@motiz88
Copy link
Copy Markdown
Contributor

@motiz88 motiz88 commented Feb 15, 2023

Summary:
Changelog:
[Android][Fixed] - Invalid prop values no longer trigger Java exceptions in the legacy renderer

Context

We are changing React Native to behave more like a browser in the sense that bad style values are not runtime errors. (See e.g. D43159284 (d6e9891), D43184380.) The recommended way for developers to ensure they are passing correct style values is to use a typechecker (TypeScript or Flow) in conjunction with E2E tests and manual spot checks.

This diff

This change is similar to D43184380, but here we target the legacy renderer on Android by (1) replacing exceptions with logging calls, (2) adding fallback values (equivalent to resetting the respective props to null) where needed, and (3) replacing null checks in ReactProp converters with instanceof checks.

Leaving the logging call sites in place (as opposed to deleting them) will be helpful if we decide that we want to repurpose these checks for a new, more visible diagnostic (though we would likely only build such a diagnostic in Fabric at this point).

Differential Revision: D43274525

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner fb-exported labels Feb 15, 2023
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D43274525

@react-native-bot react-native-bot added Bug Platform: Android Android applications. labels Feb 15, 2023
@analysis-bot
Copy link
Copy Markdown

analysis-bot commented Feb 15, 2023

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,486,092 +376
android hermes armeabi-v7a 7,806,890 +367
android hermes x86 8,963,269 +375
android hermes x86_64 8,820,265 +365
android jsc arm64-v8a 6,699,705 +255
android jsc armeabi-v7a 7,491,229 +248
android jsc x86 9,224,289 +256
android jsc x86_64 6,924,923 +257

Base commit: 167d52d
Branch: main

Summary:
Pull Request resolved: facebook#36160

Changelog:
[Android][Fixed] - Invalid prop values no longer trigger Java exceptions in the legacy renderer

## Context

We are changing React Native to behave more like a browser in the sense that **bad style values are not runtime errors**. (See e.g. D43159284 (facebook@d6e9891), D43184380.) The recommended way for developers to ensure they are passing correct style values is to use a typechecker (TypeScript or Flow) in conjunction with E2E tests and manual spot checks.

## This diff

This change is similar to D43184380, but here we target the legacy renderer on Android by (1) replacing exceptions with logging calls, (2) adding fallback values (equivalent to resetting the respective props to `null`) where needed, and (3) replacing `null` checks in `ReactProp` converters with `instanceof` checks.

Leaving the logging call sites in place (as opposed to deleting them) will be helpful if we decide that we want to repurpose these checks for a new, more visible diagnostic (though we would likely only build such a diagnostic in Fabric at this point).

Reviewed By: javache

Differential Revision: D43274525

fbshipit-source-id: 06ce18ecaaa29eade09d93480e824418f916c971
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D43274525

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Feb 15, 2023
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request has been merged in e328fc2.

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. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner Platform: Android Android applications.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants