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

[JNI Example] Call native in Java #4657

Merged
merged 1 commit into from
Jan 9, 2025

Conversation

haozheng-cobalt
Copy link
Contributor

@haozheng-cobalt haozheng-cobalt commented Jan 7, 2025

This PR serves as an example of how we should migrate Java native API to Chromium JNI standard.

Local test:
Simply ensure the native API is invoked.
haozheng@haozheng:~/chromium/src$ adb logcat | grep JNI
01-08 14:56:20.158 13226 13226 I starboard: [dev.cobalt.coat/13226:0108/225620.158117(UTC):INFO:starboard_bridge.cc(93)] JNI: StartNativeStarboard: 0xec140a60

Explanation:
Replace Java_dev_cobalt_coat_StarboardBridge_startNativeStarboard(JniEnvExt* env) with JNI_StarboardBridge_StartNativeStarboard(JNIEnv* env).
Move implementation over to starboard_bridge.cc because we should only include the _jni header from a single .cc file as the header defines functions, to avoid duplicate symbols issue.

b/372559388

@haozheng-cobalt haozheng-cobalt changed the title [JNI Example] call native in Java [WIP][JNI Example] call native in Java Jan 7, 2025
@haozheng-cobalt haozheng-cobalt changed the title [WIP][JNI Example] call native in Java [WIP][JNI Example] Call native in Java Jan 7, 2025
@haozheng-cobalt haozheng-cobalt force-pushed the jni-native branch 4 times, most recently from f6d425a to 75c0983 Compare January 8, 2025 23:12
@haozheng-cobalt haozheng-cobalt changed the title [WIP][JNI Example] Call native in Java [JNI Example] Call native in Java Jan 8, 2025
@haozheng-cobalt haozheng-cobalt self-assigned this Jan 8, 2025
@haozheng-cobalt haozheng-cobalt enabled auto-merge (squash) January 8, 2025 23:13
@haozheng-cobalt haozheng-cobalt merged commit 632168a into youtube:main Jan 9, 2025
60 of 61 checks passed
oxve added a commit to oxve/cobalt that referenced this pull request Jan 10, 2025
commit 2477e90
Merge: a73be93 632168a
Author: Ian Mindich <[email protected]>
Date:   Fri Jan 10 01:50:03 2025 -0800

    Merge branch 'main' into experimental/sharding

commit a73be93
Author: Ian Mindich <[email protected]>
Date:   Thu Jan 9 17:44:45 2025 -0800

    Add comment for fallback command

commit a5befe8
Author: Ian Mindich <[email protected]>
Date:   Thu Jan 9 17:41:22 2025 -0800

    Add if always() to test upload job to still run when test executor job fails.

commit 9cbef37
Author: Ian Mindich <[email protected]>
Date:   Thu Jan 9 17:27:59 2025 -0800

    Include GITHUB_WORKSPACE when retrieving num-shards from config file to be consistent.

commit e109e44
Author: Ian Mindich <[email protected]>
Date:   Thu Jan 9 17:26:08 2025 -0800

    Rename variables num_shards=>num_gtest_shards, shards=>gtest_shards.

commit bef8869
Author: Ian Mindich <[email protected]>
Date:   Thu Jan 9 17:11:44 2025 -0800

    Undo whitespace change.

commit 632168a
Author: Hao <[email protected]>
Date:   Thu Jan 9 15:42:58 2025 -0800

    [JNI Example] Call native in Java (youtube#4657)

    This PR serves as an example of how we should migrate Java native API to
    Chromium JNI standard.

    Local test:
    Simply ensure the native API is invoked.
    haozheng@haozheng:~/chromium/src$ adb logcat | grep JNI
    01-08 14:56:20.158 13226 13226 I starboard:
    [dev.cobalt.coat/13226:0108/225620.158117(UTC):INFO:starboard_bridge.cc(93)]
    JNI: StartNativeStarboard: 0xec140a60

    Explanation:
    Replace
    Java_dev_cobalt_coat_StarboardBridge_startNativeStarboard(JniEnvExt*
    env) with JNI_StarboardBridge_StartNativeStarboard(JNIEnv* env).
    Move implementation over to starboard_bridge.cc because we should only
    include the _jni header from a single .cc file as the header defines
    functions, to avoid duplicate symbols issue.

    b/372559388

commit c99e348
Author: Hao <[email protected]>
Date:   Thu Jan 9 14:46:26 2025 -0800

    Use SB_DCHECK in Starboard (youtube#4677)

    We should use SB_DCHECK in Starboard

    This is to address error:
    ../../starboard/android/shared/starboard_bridge.cc -o
    obj/starboard/android/shared/starboard_platform/starboard_bridge.o
    2025-01-08T23:34:08.9074020Z
    ../../starboard/android/shared/starboard_bridge.cc:112:3: error: no
    member named 'CheckFailure' in namespace 'starboard::logging'; did you
    mean '::logging::CheckFailure'?
    2025-01-08T23:34:08.9075172Z   CHECK(env);
    2025-01-08T23:34:08.9075476Z   ^~~~~~~~~~
    2025-01-08T23:34:08.9075894Z ../../base/check.h:165:28: note: expanded
    from macro 'CHECK'
    2025-01-08T23:34:08.9076719Z UNLIKELY(!(condition)) ?
    logging::CheckFailure() : EAT_CHECK_STREAM_PARAMS()
    2025-01-08T23:34:08.9077341Z                            ^~~~~~~~~
    2025-01-08T23:34:08.9077899Z ../../base/check.h:155:49: note:
    '::logging::CheckFailure' declared here
    2025-01-08T23:34:08.9078574Z [[noreturn]] IMMEDIATE_CRASH_ALWAYS_INLINE
    void CheckFailure() {

    b/372559388

commit 148c54e
Author: Dana Dahlstrom <[email protected]>
Date:   Tue Jan 7 07:00:00 2025 -0800

    Remove unused and unneeded code

    Issue: 365150653
    Reviewed-on: youtube#4675

commit 7bf51b3
Author: Bo-Rong Chen <[email protected]>
Date:   Thu Jan 9 10:35:16 2025 -0800

    [android] Fix incorrect JNI call on MediaCodecBridge (youtube#4218)

    This is the same PR as youtube#4112.

    Original commit message:

    Fix incorrect JNI call on MediaCodecBridge start(). A new argument
    CreateMediaCodecBridgeResult was added in [PR
    3672](youtube#3672). However, the
    corresponding JNI call didn't change, which could cause native crash by
    player_worker.

    b/366746149
    b/320568573
    b/364415911

commit 675eee9
Author: Hao <[email protected]>
Date:   Thu Jan 9 10:30:04 2025 -0800

    Move include order for starboard_bridge (youtube#4670)

    b/372559388

commit 15f8186
Author: Dana Dahlstrom <[email protected]>
Date:   Mon Jan 6 18:00:00 2025 -0800

    Mount KOKORO_ARTIFACTS_DIR as a volume

    … instead of mounting the git/src subdirectory, because
    CIPD creates hard links from that directory to files under its parent.

    Fixed: 382250271
    Issue: 365150653
    Reviewed-on: youtube#4665

commit 67032e0
Author: Bo-Rong Chen <[email protected]>
Date:   Thu Jan 9 01:18:48 2025 -0800

    [android] Fix software video decoder fallback (youtube#4216)

    This is the same PR as youtube#4111.

    Original commit message:

    [PR 3103](youtube#3103) fixed MIME
    attribute "framerate" that enforces a low resolution and low fps
    playback to use software video decoder.

    However, If software video decoder is not available, Cobalt should
    fallback to hardware video decoder.

    b/328537630

commit 4b517f0
Merge: b5905df 96e82a5
Author: Dana Dahlstrom <[email protected]>
Date:   Wed Jan 8 14:00:00 2025 -0800

    Restore media/base/demuxer_memory_limit_starboard.cc

    Issue: 322027866
    Reviewed-on: https://github.com/youtube/cobalt/pull/

commit b5905df
Author: thorsten sideb0ard <[email protected]>
Date:   Wed Jan 8 16:54:52 2025 -0800

    Add CobaltContentRendererClient (youtube#4661)

    b/388335917

    * Add Cobalt specific ContentRendererClient. (copied from
    ShellContentRendererClient)

    * Remove media modifications from ShellContentRendererClient

commit 39d2b38
Author: Ian Mindich <[email protected]>
Date:   Wed Jan 8 16:50:24 2025 -0800

    Make artifact names unique, and download artifacts according to a pattern

commit 26783b4
Author: Austin Osagie <[email protected]>
Date:   Wed Jan 8 16:32:43 2025 -0800

    [media] Create SbPlayerState utility function (youtube#4668)

    Creates GetPlayerStateName(), which will return the name of the passed
    SbPlayerState as a const char*.

    b/376316272

commit c5e7b40
Author: Ian Mindich <[email protected]>
Date:   Wed Jan 8 14:41:22 2025 -0800

    call FromJson for array

commit 543e744
Author: Ian Mindich <[email protected]>
Date:   Wed Jan 8 13:57:10 2025 -0800

    Update xml path to write test results to the correct location.

commit 40417f8
Author: Ian Mindich <[email protected]>
Date:   Wed Jan 8 13:55:26 2025 -0800

    Add missing checkout step to test upload job.

commit b1a8963
Author: Ian Mindich <[email protected]>
Date:   Wed Jan 8 13:54:00 2025 -0800

    Populate num shards from yaml configs.

commit 02a217b
Author: Ian Mindich <[email protected]>
Date:   Wed Jan 8 13:00:20 2025 -0800

    Ensure files uploaded by each shard have unique paths, and use glob patterns to pick up the files when downloading.

commit 122792a
Author: Ian Mindich <[email protected]>
Date:   Wed Jan 8 12:48:46 2025 -0800

    Include shard number in test steps.

commit 01889e2
Author: Ian Mindich <[email protected]>
Date:   Tue Jan 7 14:16:01 2025 -0800

    Process test results regardless of test job outcome.

commit 4f16ae1
Author: Ian Mindich <[email protected]>
Date:   Tue Jan 7 13:06:07 2025 -0800

    Add back all test targets

commit e2efd64
Author: Ian Mindich <[email protected]>
Date:   Tue Jan 7 11:56:06 2025 -0800

    Increase shard count to 10.

commit 902d80c
Author: Ian Mindich <[email protected]>
Date:   Mon Jan 6 21:30:42 2025 -0800

    Try 6 shards, 5 shards taking ~57 seconds to run tests

commit ff27fc7
Author: Ian Mindich <[email protected]>
Date:   Mon Jan 6 20:57:25 2025 -0800

    Make artifact names unique based on shard

commit 476d3b6
Author: Ian Mindich <[email protected]>
Date:   Mon Jan 6 19:10:48 2025 -0800

    Add base_unittests

commit a672f68
Author: Ian Mindich <[email protected]>
Date:   Mon Jan 6 19:05:06 2025 -0800

    Split up test binaries across 5 shards

commit 33d2030
Author: Ian Mindich <[email protected]>
Date:   Mon Jan 6 18:44:56 2025 -0800

    indenting

commit 91ad8f4
Author: Ian Mindich <[email protected]>
Date:   Mon Jan 6 18:34:56 2025 -0800

    Split up test running and test reporting into separate jobs.
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.

2 participants