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

[Upstream] Remove assumptions on super's description #36374

Closed
wants to merge 1 commit into from

Conversation

Saadnajmi
Copy link
Contributor

@Saadnajmi Saadnajmi commented Mar 5, 2023

Summary

This is a change upstreamed from our fork, React Native macOS: microsoft#1088

Original description:

We hit some crashes where replacing the chars in the string in the description was happening at an invalid range. That caused investigation into what these description methods are doing. We shouldn't have code assuming super's description will return in a certain format. Instead, just append any additional info we want to add to the end of the description.

Changelog

[IOS] [CHANGED] -Remove assumptions on super's description

Test Plan

CI should pass

@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: Microsoft Partner: Microsoft Partner labels Mar 5, 2023
@analysis-bot
Copy link

analysis-bot commented Mar 5, 2023

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,508,872 -2,003
android hermes armeabi-v7a 7,822,848 -3,419
android hermes x86 8,986,447 -3,149
android hermes x86_64 8,842,620 -3,380
android jsc arm64-v8a 9,135,684 -2,189
android jsc armeabi-v7a 8,325,234 -3,601
android jsc x86 9,188,637 -3,326
android jsc x86_64 9,447,629 -3,546

Base commit: 96659f8
Branch: main

@javache
Copy link
Member

javache commented Mar 6, 2023

Can you provide more details on the crash you've been seeing? Agree that you usually don't need this in production, but when they do show up in exception messages or log messages from internal bug reports we've gotten a lot of value out of them.

@Saadnajmi
Copy link
Contributor Author

Can you provide more details on the crash you've been seeing? Agree that you usually don't need this in production, but when they do show up in exception messages or log messages from internal bug reports we've gotten a lot of value out of them.

The crash was macOS specific (the format of description differs slightly from iOS, so one of them caused a crash). I'll dig up the into + the other fix we had.

@Saadnajmi
Copy link
Contributor Author

Saadnajmi commented Mar 6, 2023

@javache The other half of the "fix" we made is here: microsoft#1088

These descriptions were made by replacing a character in the existing description that existed on iOS, but not on macOS. That caused a crash for us. We fixed this by instead just appending to the super class's description, rather than making assumptions about its structure and modifying it.

If you still like this change, I can roll that refactor into this PR as well. Or I can make a change with just the refactor,but not limiting description to debug if that works better internally. I know you mentioned the description is useful internally (I'm not sure if in debug or release) so I'd understand if you'd rather not take either change altogether.

@javache
Copy link
Member

javache commented Mar 7, 2023

Yes, the replacing of super's description is purely cosmetic, so the changes in https://github.com/microsoft/react-native-macos/pull/1088/files would make sense to pull in upstream.

My preference would be to not add the #if RCT_DEBUG guards here and just port over the fix. If there's a desire to have release builds without these DEBUG methods, we should look at a different compiler flag to optionally enable that.

@Saadnajmi
Copy link
Contributor Author

Yes, the replacing of super's description is purely cosmetic, so the changes in https://github.com/microsoft/react-native-macos/pull/1088/files would make sense to pull in upstream.

My preference would be to not add the #if RCT_DEBUG guards here and just port over the fix. If there's a desire to have release builds without these DEBUG methods, we should look at a different compiler flag to optionally enable that.

We actually just use #if DEBUG in our fork. I changed it to RCT_DEBUG things that was more appropriate. Would you prefer that? Or other something like if #HAS_DESCRIPTIONS ?

@Saadnajmi
Copy link
Contributor Author

@javache Looking into it, I think you're right that description shouldn't be debug only. Otherwise, this wouldn't exist :D
https://developer.apple.com/documentation/objectivec/1418956-nsobject/1418703-debugdescription?language=objc

I updated this PR to upstream the refactor, and not the DEBUG ifdefs.

@Saadnajmi Saadnajmi changed the title [Upstream] Class descriptions are debug-only [Upstream] Remove assumptions on super's description Mar 7, 2023
@facebook-github-bot
Copy link
Contributor

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

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

@javache merged this pull request in a5bc6f0.

@Saadnajmi Saadnajmi deleted the description branch April 6, 2023 23:28
OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
Summary:
This is a change upstreamed from our fork, React Native macOS: microsoft#1088

Original description:

>We hit some crashes where replacing the chars in the string in the description was happening at an invalid range. That caused investigation into what these description methods are doing. We shouldn't have code assuming super's description will return in a certain format. Instead, just append any additional info we want to add to the end of the description.

## Changelog

[IOS] [CHANGED] -Remove assumptions on super's description

Pull Request resolved: facebook#36374

Test Plan: CI should pass

Reviewed By: cipolleschi

Differential Revision: D43906367

Pulled By: javache

fbshipit-source-id: f83a67c5890ad1f8a73bc644be1f0f8b22b1a371
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. p: Microsoft Partner: Microsoft Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants