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

Create StarboardBridge native class with jni_generator #4606

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

haozheng-cobalt
Copy link
Contributor

@haozheng-cobalt haozheng-cobalt commented Dec 18, 2024

b/372559388

This PR configures jni_generator for cobalt_apk_java.
It creates the corresponding native class StarboardBridge for cobalt/android/apk/app/src/main/java/dev/cobalt/coat/StarboardBridge.java, adhering to Chromium's JNI standards.
The StarboardBridge native class is implemented as a singleton and is initialized with the same JNIEnv and jobject used when calling the Starboard custom JniEnvExt::Initialize function.
Additionally, it updates the JNI function calls in starboard/android/shared/application_android.cc to align with Chromium's modern JNI standards.

This PR amends the reverted PR #4545

There was an issue in the reverted PR that there are old annotations @UsedByNative embeded in the inner function calls in getResourceOverlay, somehow making the app not able to launch..
Culprit ->
https://github.com/youtube/cobalt/pull/4545/files#diff-22285847addbd15025f71dadd357129f86573e042655067048f94fae301fb1d3R480.

We can not blindly replace @UsedByNative with @CalledByNative, when switching to @CalledByNative, we should make sure to replace all occurrence of @UserByNative inside, and implement the new JNI template functions. I don't get why compiler didn't complain about the getResourceOverlay issue tho.

@haozheng-cobalt haozheng-cobalt changed the title Migrate StarboardBridge to Chromium standard JNI Create StarboardBridge native class with jni_generator Dec 18, 2024
@haozheng-cobalt haozheng-cobalt self-assigned this Dec 18, 2024
@haozheng-cobalt haozheng-cobalt enabled auto-merge (squash) December 18, 2024 21:00
Copy link
Contributor

@johnxwork johnxwork left a comment

Choose a reason for hiding this comment

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

SG if this PR creates no runtime crashes.

@haozheng-cobalt haozheng-cobalt merged commit 1322f53 into youtube:main Dec 19, 2024
69 of 70 checks passed
"//starboard/common",
"//starboard/shared/starboard/media:media_util",
"//starboard/shared/starboard/player/filter:filter_based_player_sources",
]

deps = [
"//base",
Copy link
Contributor

Choose a reason for hiding this comment

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

@andrewsavage1 Just wanted to double check what the guideline is to add dependency from Starboard to a Chromium target (e.g. //base).

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for bringing this up, as we explicitly disallow //starboard to depend on //base (and most Chromium targets, as the majority of them depend on Starboard). @haozheng-cobalt this should be refactored to take this into account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants