-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -434,9 +434,9 @@ public void run() { | |
|
||
if (mShouldLogContentAppeared) { | ||
mShouldLogContentAppeared = false; | ||
|
||
if (mJSModuleName != null) { | ||
ReactMarker.logMarker(ReactMarkerConstants.CONTENT_APPEARED, mJSModuleName, mRootViewTag); | ||
String jsModuleName = getJSModuleName(); | ||
if (jsModuleName != null) { | ||
Kudo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ReactMarker.logMarker(ReactMarkerConstants.CONTENT_APPEARED, jsModuleName, mRootViewTag); | ||
} | ||
} | ||
} | ||
|
@@ -632,7 +632,7 @@ public void setEventListener(@Nullable ReactRootViewEventListener eventListener) | |
|
||
@Override | ||
public String getJSModuleName() { | ||
return Assertions.assertNotNull(mJSModuleName); | ||
return mJSModuleName; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
} | ||
|
||
@Override | ||
|
There was a problem hiding this comment.
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 ofmJSModuleName
everywhere in this file).There was a problem hiding this comment.
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 thatgetJSModuleName()
should always be non-nullable. otherwise, ifgetJSModuleName()
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.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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 withgetJSModuleName
and removing the null checks should be fine.There was a problem hiding this comment.
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.