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

Implementing Asynchronous Advertising ID Retrieval for H5vccSystem #4794

Merged
merged 21 commits into from
Feb 8, 2025

Conversation

zhongqiliang
Copy link
Contributor

@zhongqiliang zhongqiliang commented Jan 30, 2025

  1. A new mojom interface for H5vccSystem is created, including an asynchronous API method to retrieve the advertising ID.
  2. The mojom server implementation handles the request by calling JNI (Java Native Interface) functions. These JNI calls will interact with the StarboardBridge to fetch the actual advertising ID value.
  3. The renderer client then utilizes the mojom interface to call the asynchronous method and retrieve the advertising ID.

Tested on devtools, https://screenshot.googleplex.com/43HotkbLgJSQdx3

  1. Added web_tests for the mojom interface.
    // Compile the web_test
    cobalt/build/gn.py -p linux-x64x11 -C devel &&
    autoninja -C out/linux-x64x11_devel blink_wpt_tests &&
    autoninja -C out/linux-x64x11_devel dump_syms &&
    autoninja -C out/linux-x64x11_devel minidump_stackwalk &&
    autoninja -C out/linux-x64x11_devel cobalt/browser/h5vcc_system/public/mojom:mojom_js
    // run the web_test
    third_party/blink/tools/run_web_tests.py -t linux-x64x11_devel wpt_internal/h5vcc/h5vcc-system

b/377049113

@zhongqiliang zhongqiliang changed the title Add mojom for H5vccSystem. Implementing Asynchronous Advertising ID Retrieval for H5vccSystem Feb 4, 2025
@zhongqiliang zhongqiliang marked this pull request as ready for review February 4, 2025 18:49
@zhongqiliang zhongqiliang requested review from a team as code owners February 4, 2025 18:49
Copy link
Contributor

@andrewsavage1 andrewsavage1 left a comment

Choose a reason for hiding this comment

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

LGTM other than one (large) rename. Were you able to test this i.e. via devtools?

cobalt/browser/BUILD.gn Show resolved Hide resolved
Copy link
Contributor

@yell0wd0g yell0wd0g left a comment

Choose a reason for hiding this comment

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

Looking close, can be simplified and also needs plugging the JS Mojo Mock.

Copy link
Contributor

@hlwarriner hlwarriner left a comment

Choose a reason for hiding this comment

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

I left one comment and also agree with Miguel that the web test should be updated. Otherwise, looks good!

.pre-commit-config.yaml Outdated Show resolved Hide resolved
Copy link
Contributor

@yell0wd0g yell0wd0g left a comment

Choose a reason for hiding this comment

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

LGTM with a TODO(b/...) in void H5vccSystemImpl::GetAdvertisingId() to try and remove the Mojo-to-C++-to-Java (in favour of Mojo-to-Java directly). @andrewsavage1 volunteered to do so, but adding a bug and a TODO should be fast.

(I think I left a comment like this but perhaps it was in #4853).

Copy link
Contributor

@hlwarriner hlwarriner left a comment

Choose a reason for hiding this comment

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

Left one minor comment but otherwise lgtm.

@zhongqiliang zhongqiliang enabled auto-merge (squash) February 7, 2025 21:46
@kaidokert
Copy link
Member

Linux builds are failing with a real build error - missing jni.h include path. It probably needs an extra dependency in GN code.

@andrewsavage1
Copy link
Contributor

Linux builds are failing with a real build error - missing jni.h include path. It probably needs an extra dependency in GN code.

You'll likely need to depend on //starboard($starboard_toolchain) directly instead of //starboard/android/shared:starboard_platform. I'll come back and clean this up so we can depend on //starboard:starboard_group instead.

Alternatively you could depend on //starboard:starboard_group and add a // nogncheck for the android-specific includes that I can clean up later.

@zhongqiliang zhongqiliang merged commit 7bbf2ef into youtube:main Feb 8, 2025
133 checks passed
@zhongqiliang zhongqiliang deleted the h5vcc_system_mojom branch February 8, 2025 16:43
@hlwarriner
Copy link
Contributor

LGTM with a TODO(b/...) in void H5vccSystemImpl::GetAdvertisingId() to try and remove the Mojo-to-C++-to-Java (in favour of Mojo-to-Java directly). @andrewsavage1 volunteered to do so, but adding a bug and a TODO should be fast.

(I think I left a comment like this but perhaps it was in #4853).

@yell0wd0g IIUC you're suggesting that for cross-platform Mojo interfaces, like this one, we have both:

  • A Java Mojo impl that leverages Java Mojo bindings (built only for ATV)
  • A C++ Mojo impl that leverages C++ Mojo bindings (built only for 3P).

I was looking into Mojo's Java bindings and saw these recommendations from https://chromium.googlesource.com/chromium/src/mojo/+/HEAD/public/java/bindings/README.md#should-i-or-should-i-not-use-the-java-bindings:

"Java bindings typically only make sense on the browser side and for Android devices where there is some service that‘s unique to Android. As such, Java bindings are typically rarely used, but they are used sometimes. When implementing a cross-platform feature or service, it’s probably more appropriate to use C++ Mojo bindings and (if necessary) plumb the platform-specific code implemented in Java via JNI."

From that doc it sounds like one of the primary reasons for that recommendation is that the Java bindings are missing some features: https://chromium.googlesource.com/chromium/src/mojo/+/HEAD/public/java/bindings/README.md#notable-lacking-features.

So do you think we should include both Java and C++ Mojo impls for Mojo interfaces where we don't need those features, and just C++ Mojo impls where we do? Are there examples from upstream where both Java and C++ implementations are provided for cross-platform Mojo interfacaes?

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

Successfully merging this pull request may close these issues.

5 participants