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

Remove RCTBridgeWillInvalidateModulesNotification observer from RCTDeviceInfo #45012

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hromovp
Copy link

@hromovp hromovp commented Jun 17, 2024

Summary:

I noticed that after application reload useWindowDimensions stops listening to dimension changes on app orientation change, width and height had always the same value regardles of orientation.
On further investigation it became clear that invalidating method were running twice on turndown, which led me to believe that turbomodule already invalidating imperatively (as stated in the comment by author of workaround) and calling notification handler invalidates newly created module, as a result nothing handles screen size changes.

Also I removed codesigning for running tests as its requesting development team and failing.

Changelog:

  • Removed workaround for invalidating RCTDeviceInfo module;
  • Removed codesigning for tests;

[IOS] [REMOVED] - Remove RCTBridgeWillInvalidateModulesNotification observer from RCTDeviceInfo

Test Plan

  • set brakepoint to invalidate and initialize methods of react-native/packages/react-native/React/CoreModules/RCTDeviceInfo.mm;
  • trigger application reload;

current state: on reload invalidate method runs twice, removing observers for both previous and new instances of RCTDeviceInfo class, you can check by memory adress of the instance on intiallize and invalidate calls

expected: on reload invalidate method runs once removing previous instance of the class, every subsequent reload it does same.

disable codesigning for tests
@facebook-github-bot
Copy link
Contributor

Hi @hromovp!

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 cla@meta.com. Thanks!

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@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. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Jun 17, 2024
@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 20,443,786 -4
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 23,642,481 +6
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: 9491ded
Branch: main

@hromovp hromovp changed the title Remove RCTBridgeWillInvalidateModulesNotificationobserver from RCTDeviceInfo Remove RCTBridgeWillInvalidateModulesNotification observer from RCTDeviceInfo Jun 17, 2024
Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

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

Hi @hromovp, thanks for the contribution.
I don't think we can proceed with this, given that we needed to listen to that event to make sure that RCTDeviceInfo is invalidated.

Calling the event twice, in the tear-down step should be idempotent, so it should not cause any issue.

Out of curiosity: which configuration are you using?
Are you on the new architecture? Are you using bridgeless or not?

@@ -80,7 +80,9 @@ runTests() {
-scheme RNTester \
-sdk iphonesimulator \
-destination "platform=iOS Simulator,name=$IOS_DEVICE,OS=$IOS_TARGET_OS" \
"${SKIPPED_TESTS[@]}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you do this in a separate PR, please?

Comment on lines -83 to -85
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(invalidate)
name:RCTBridgeWillInvalidateModulesNotification
Copy link
Contributor

Choose a reason for hiding this comment

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

We can't really remove this.
If you look at the change that introduced this, it solves another bug: #42120.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, the PR that introduced this is d46d80d and a further fix later in 91279a8

@hromovp
Copy link
Author

hromovp commented Jun 19, 2024

Hi @cipolleschi, I am using 0.74.2 with bridge.
The problem with this is that notification's center notification arriving after the teardown already happened and new instance was initialized, so its invalidating newly created instance. It happends for me when I trigger RCTTriggerReloadCommandListeners

I am fully aware of the issue this was resolving and therefore I have only removed notification that is, to my understanding, redundant.

Despite that, I understand your position and tbh main reason for creating this PR was to notify RN team that there could be issue with this.
I will take my time to submit PR for tests later this week.
Thank you for review!

@cipolleschi
Copy link
Contributor

The New Architecture with Bridge is not the suggested setup anymore, and we will probably not want to fix it.

If this problem is happening in the Old Architecture, then we need to look into it.

Which one of the two scenarios are you into?

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. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants