import android-games-sdk patches for mainLooper + onCreate hook#230
Merged
Conversation
This imports the SDK from commit 30b8bfcc9a12942d1268820e8a83d7643e99ee92, from: https://github.com/rust-mobile/android-games-sdk/commits/android-activity-4.0.0 this includes these patches: # PATCH: Add mainLooper to android_app Track the Looper for the Java main/UI thread in the android_app. This makes it possible to add file descriptors and callbacks to the Java UI Looper from the android_main thread. This needs to be initialized by the android_native_app_glue before spawning the android_main thread because the looper needs to be discovered via `ALooper_forThread` while still running on the Java main thread (in the onCreate callback). # PATCH: Enable Rust glue to hook into onCreate This declares an extern `_rust_glue_on_create_hook` that is called from `GameActivity` `onCreate` native method callback, before the `android_main` thread is spawned. This gives Rust code an opportunity to run code and initialize state while still running on the Java main/UI thread. For example, this could be used to initialize JNI bindings while we can assume that the current thread has an associated ClassLoader that will be able to find application classes. It may also be a convenient place to make some initial JNI calls into Android SDK APIs that can only be used from the Java main thread. # Updated import-games-sdk.sh to remove symlinks While updating the SDK the import script has been updated to remove any symlinks which make it difficult to build android-activity from Git on Windows. Note: the symlinks were redundant based on how the include paths were already configured in `build.rs`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This imports the SDK from commit
30b8bfcc9a12942d1268820e8a83d7643e99ee92, from:
https://github.com/rust-mobile/android-games-sdk/commits/android-activity-4.0.0
this includes these patches:
PATCH: Add mainLooper to android_app
Track the Looper for the Java main/UI thread in the android_app.
This makes it possible to add file descriptors and callbacks to the Java UI Looper from the android_main thread.
This needs to be initialized by the android_native_app_glue before spawning the android_main thread because the looper needs to be discovered via
ALooper_forThreadwhile still running on the Java main thread (in the onCreate callback).PATCH: Enable Rust glue to hook into onCreate
This declares an extern
_rust_glue_on_create_hookthat is called fromGameActivityonCreatenative method callback, before theandroid_mainthread is spawned.This gives Rust code an opportunity to run code and initialize state while still running on the Java main/UI thread.
For example, this could be used to initialize JNI bindings while we can assume that the current thread has an associated ClassLoader that will be able to find application classes.
It may also be a convenient place to make some initial JNI calls into Android SDK APIs that can only be used from the Java main thread.
Updated import-games-sdk.sh to remove symlinks
While updating the SDK the import script has been updated to remove any symlinks which make it difficult to build android-activity from Git on Windows.
Note: the symlinks were redundant based on how the include paths were already configured in
build.rsTracking the Java main thread Looper via
app->mainLooperwill enable us to update #198 so that it also supports theGameActivitybackend.The onCreate hook will make it possible to support an (optional) "android_on_create" application entry point that is guaranteed to run on the Java main / UI thread. For example applications may find this convenient for initialization of state that involves using JNI to call SDK APIs that are only usable from the main Java thread. (E.g. re: #169 + #82)
(these will be addressed in follow up PRs though)
This PR initially adds a stub
_rust_glue_on_create_hookjust to ensureandroid-activitylinks with the these imported changes, and this will be update by follow up PRs.Note:
generate-bindings.shwas re-run after importing these SDK changes