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 #4545

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

haozheng-cobalt
Copy link
Contributor

@haozheng-cobalt haozheng-cobalt commented Dec 9, 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.

@haozheng-cobalt haozheng-cobalt self-assigned this Dec 9, 2024
@haozheng-cobalt haozheng-cobalt force-pushed the jni-1209 branch 4 times, most recently from 84430a4 to 73034db Compare December 12, 2024 19:18
@haozheng-cobalt haozheng-cobalt changed the title Migrate StarboardBridge to Chromium standard JNI [WIP] Migrate StarboardBridge to Chromium standard JNI Dec 12, 2024
@haozheng-cobalt haozheng-cobalt force-pushed the jni-1209 branch 3 times, most recently from 2611aed to 87fa6c1 Compare December 17, 2024 00:24
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.

Hey Hao, I'm not sure if the PR is ready for review yet since the description has WIP. Ping me when you need reviews.

@haozheng-cobalt haozheng-cobalt force-pushed the jni-1209 branch 2 times, most recently from c2faad2 to 4f85854 Compare December 17, 2024 18:36
@haozheng-cobalt haozheng-cobalt changed the title [WIP] Migrate StarboardBridge to Chromium standard JNI Create StarboardBridge native class with jni_generator Dec 17, 2024
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.

This is a nice first step. Can you put a comment in PR or in the FR about the next steps?

@haozheng-cobalt haozheng-cobalt enabled auto-merge (squash) December 17, 2024 18:59
@haozheng-cobalt haozheng-cobalt enabled auto-merge (squash) December 17, 2024 20:13
@haozheng-cobalt haozheng-cobalt merged commit 4580609 into youtube:main Dec 17, 2024
71 of 73 checks passed
haozheng-cobalt added a commit that referenced this pull request Dec 18, 2024
haozheng-cobalt added a commit that referenced this pull request Dec 19, 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.
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.

3 participants