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

Add ReactMarkerConstants.CONTENT_APPEARED support on Android #43620

Closed
wants to merge 4 commits into from

Conversation

Kudo
Copy link
Contributor

@Kudo Kudo commented Mar 22, 2024

Summary:

Add the ReactMarkerConstants.CONTENT_APPEARED support on Android in bridgeless mode. This is an important marker for TTI measurement.

Changelog:

[ANDROID] [ADDED] - Add the ReactMarkerConstants.CONTENT_APPEARED support on Android in bridgeless mode.

Test Plan:

adding this on RNTesterActivity to see if the log is executed

ReactMarker.addListener { name, tag, instanceKey ->
  if (name == ReactMarkerConstants.CONTENT_APPEARED) {
    Log.i("XXX", "XXX")
  }
}

@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. Contributor A React Native contributor. p: Expo Partner: Expo Partner labels Mar 22, 2024
@analysis-bot
Copy link

analysis-bot commented Mar 22, 2024

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 20,248,988 -115,290
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 23,454,719 -114,804
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: 42f136d
Branch: main

@Kudo Kudo marked this pull request as ready for review March 22, 2024 18:09
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Mar 22, 2024
@Kudo
Copy link
Contributor Author

Kudo commented Mar 29, 2024

appreciated if @cortinico could take a look for this pr.

@cortinico
Copy link
Contributor

cc @rubennorte

@Kudo Kudo force-pushed the @kudo/bridgeless/CONTENT_APPEARED branch from b3e2a3e to 813c6b7 Compare April 11, 2024 07:19
@Kudo
Copy link
Contributor Author

Kudo commented Apr 11, 2024

rebase main to fix conflict

@Kudo
Copy link
Contributor Author

Kudo commented Apr 24, 2024

much appreciated if @rubennorte could help to take a look for this pr

@Kudo Kudo force-pushed the @kudo/bridgeless/CONTENT_APPEARED branch from 813c6b7 to a237918 Compare June 11, 2024 08:48
if (mJSModuleName != null) {
ReactMarker.logMarker(ReactMarkerConstants.CONTENT_APPEARED, mJSModuleName, mRootViewTag);
}
String jsModuleName = getJSModuleName();
Copy link
Contributor

@rubennorte rubennorte Jun 11, 2024

Choose a reason for hiding this comment

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

Sorry for the very late review.

This feels risky because getJSModuleName asserts, which could introduce new crashes. I understand you changed this so we can override it, but we should either try/catch here or create a new method that doesn't assert and use it instead (and maybe use it to access instead of mJSModuleName everywhere in this file).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for having the comment. after this pr, mJSModuleName is only access from the getter.

i was thinking that assertion for getJSModuleName() could help us catching the issue as early as possible. if we believe that getJSModuleName() should always be non-nullable. otherwise, if getJSModuleName() could be nullable, i don't really like try-catch or introducing new method, having an alternative e6a722d change, please let me know which makes more sense to you.

Copy link
Contributor

Choose a reason for hiding this comment

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

could help us catching the issue as early as possible

I agree with this when adding a new API, but modifying an API to introduce this, if the previous behavior wasn't crashing, is not ideal.

Given that we already have some callers in the critical path (e.g.: startSurface) that were using the getter with the assert, I think it might be safe to continue using it, even for this use case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

alright, if that's more toward existing call paths, having try-catch makes more sense than introducing new method.
i've updated the pr to have try-catch. please check again if that makes sense to you. thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I think you misunderstood. I meant that you can keep the implementation you had replacing all usages with getJSModuleName with the assert because we were already calling that when loading a new surface. If there were cases where it was defined, that should've thrown an error in those cases too. So replacing all with getJSModuleName and removing the null checks should be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry i was easily mistaken. i've reset the branch to the previous version. hopes that is correct.

@Kudo Kudo force-pushed the @kudo/bridgeless/CONTENT_APPEARED branch from 56862e0 to e6a722d Compare June 11, 2024 16:25
@@ -28,6 +28,7 @@ public interface ReactRoot {
@Nullable
Bundle getAppProperties();

@Nullable
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 remove this @Nullable annotation and all the new asserts on this diff

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated. does the diff look correct now?

@@ -632,7 +632,7 @@ public void setEventListener(@Nullable ReactRootViewEventListener eventListener)

@Override
public String getJSModuleName() {
return Assertions.assertNotNull(mJSModuleName);
return mJSModuleName;
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we were adding back the assertion. Can you please update this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

haha it looks like the original version is more correct. sorry i totally misunderstood what you said before.
updated and please let me know if there are any other feedback.

@facebook-github-bot
Copy link
Contributor

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

Copy link
Contributor

@rubennorte rubennorte left a comment

Choose a reason for hiding this comment

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

Thanks for adding support for this in the new architecture! I'm going to import this at Meta and test it internally before merging.

@Kudo
Copy link
Contributor Author

Kudo commented Jun 12, 2024

much appreciated @rubennorte. sorry i spent you a while to address review feedback back-and-forth .

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jun 13, 2024
@facebook-github-bot
Copy link
Contributor

@rubennorte merged this pull request in 5da9fdf.

Copy link

This pull request was successfully merged by @Kudo in 5da9fdf.

When will my fix make it into a release? | How to file a pick request?

@facebook-github-bot
Copy link
Contributor

This pull request has been reverted by 7e0f894.

@Kudo
Copy link
Contributor Author

Kudo commented Jun 13, 2024

oh no i'm sorry if that cause some breaks in meta internally. let me know if there's anything i can help with.

@rubennorte
Copy link
Contributor

oh no i'm sorry if that cause some breaks in meta internally. let me know if there's anything i can help with.

Hey, don't worry. It's just one CI job that didn't run correctly in the original PR. I'll re-commit it with the fix today/tomorrow.

@Kudo
Copy link
Contributor Author

Kudo commented Jun 13, 2024

oh no i'm sorry if that cause some breaks in meta internally. let me know if there's anything i can help with.

Hey, don't worry. It's just one CI job that didn't run correctly in the original PR. I'll re-commit it with the fix today/tomorrow.

thanks! feel free to let me know if there's anything i can help.

facebook-github-bot pushed a commit that referenced this pull request Jun 13, 2024
…ts.CONTENT_APPEARED support on Android"

Summary:
Changelog: [ANDROID] [ADDED] - Add the ReactMarkerConstants.CONTENT_APPEARED support on Android in bridgeless mode.

This re-applies #43620 which was reverted because a CI job started failing because we forgot to update `packages/react-native/ReactAndroid/api/ReactAndroid.api`.

Reviewed By: cortinico

Differential Revision: D58535868

fbshipit-source-id: 9eec33c5e798850a7434a6c391abf2fc3fc9d0a6
Titozzz pushed a commit that referenced this pull request Jul 1, 2024
…ts.CONTENT_APPEARED support on Android"

Summary:
Changelog: [ANDROID] [ADDED] - Add the ReactMarkerConstants.CONTENT_APPEARED support on Android in bridgeless mode.

This re-applies #43620 which was reverted because a CI job started failing because we forgot to update `packages/react-native/ReactAndroid/api/ReactAndroid.api`.

Reviewed By: cortinico

Differential Revision: D58535868

fbshipit-source-id: 9eec33c5e798850a7434a6c391abf2fc3fc9d0a6
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. Contributor A React Native contributor. Merged This PR has been merged. p: Expo Partner: Expo Partner Reverted 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.

5 participants