Skip to content

Update GameActivity from v2.0.2 to v4.0.0 #188

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

Open
jb55 opened this issue Mar 12, 2025 · 8 comments · May be fixed by #191
Open

Update GameActivity from v2.0.2 to v4.0.0 #188

jb55 opened this issue Mar 12, 2025 · 8 comments · May be fixed by #191

Comments

@jb55
Copy link

jb55 commented Mar 12, 2025

As per some discussions here:

It seems like there are upstream GameTextInput fixes since v2.0.2, so we should try to update our local version. The plan is to re-apply our local patches on top of v4.0.0.

It's a bit of a pain to keep these in sync, there have been discussions around creating a RustActivity so we don't have to keep resyncing with GameActivity, but I'll leave that for another issue.

git clone https://android.googlesource.com/platform/frameworks/opt/gamesdk
v2.0.2: 8a7bb9cb2792cf3f57ea6d54a7f2283ed05c4c2d
v4.0.0: 7f54c13ee549e4511dcdc15a8ca73864e87be605

Patches to apply

Last import on repo:

commit c471fdf903262c1cafa560065ce4af2531cf1aae (last-import)
Author: Alexis <[email protected]>
Date:   Sun Jun 25 22:28:45 2023 -0400

    Import unmodified GameActivity 2.0.2 Source
    
    See: https://developer.android.com/jetpack/androidx/releases/games#games-activity_version_20_2

git log --oneline last-import.. -- android-activity/game-activity-csrc
d6345abb2a08 GameActivity PATCH: rename C symbols that need export
202ab4c1e988 GameActivity PATCH: Rename android_main _rust_glue_entry
3e3fb84c0350 GameActivity PATCH: remove unused variable
d2d18154d9cf GameActivity PATCH: Support InputAvailable events
2a2f27637f79 GameActivity PATCH: fix deadlocks in java callbacks after app destroyed
41f30c39ad09 Expose TextEvent and input method state
6b3307410e95 GameActivity PATCH: Don't read unicode via getUnicodeChar

Patch plan

The plan is to save these as patches and then apply them on top:

git format-patch -o patches last-import.. -- android-activity/game-activity-csrc
git am patches/*.patch

One challenge is that there have been some formatting commits upstream:

Reformat GameTextInput sources

So I may need to format our patches first? bleh.

Changes in v2.0.2..v4.0.0

git log --format=%s --no-merges v2.0.2..v4.0.0 -- game-text-input/ game-activity/ | sort -u
Add a native callback on SW keyboard visibility change
add a note about supported input types for GameTextInput
Add a support of multi-line and single-line modes in GameTextInput
add backing types for all enumerations in GameActivity/GameTextInput
Add bitfield definitions for GameActivity_setImeEditorInfo
add comments on reserved range for android_app_write_cmd()
add concise comments on GameActivity locales support
add cpp files into prefabs for GameActivity/GameTextInput
add dependencies to prefab metadata
Added GameActivity_restartInput method.
add error handling in GameTextInput
Add navigation using left and right arrow keys to gametextinput.
Add onEditorAction callback
add physical volume buttons to the ignore list for GameTextInput
add proper SDK version reporting to GameActivity
bump GameActivity and GameTextInput to 4.0.0alpha01
bump versions of GameActivity and GameTextInput to 3.0
Clear focus when soft keyboard is hidden (either by user or by the client).
convert all sources to Google's code style
Correctly destroy GameActivityMotionEvent
fix AGDK tests
fix a race condition in GameTextInput
fix code-style in GameActivity
fix deletion with text selection
fix Doxygen comments in GameActivityEvents_internal.h
fixed multiline mode
fixed state updates propagation
Fix external directory code. Bug: 323404241 Test: Run  agdktunnel
fix for hardware and software keyboards being out of sync
Fix GameActivity getLocale* functions.
Fix GameActivityMotionEvent_getHistoricalAxisValue index calculation
fix GameTextInput editing functions
Fix GameTextInput_hideIme comment
fix hiddenKeyboard variable updates
Fix improper button forwarding in GameTextInput
Fix incorrect JNI params in GA/GTI
fix 'keyboard' variable updates
fix null pointer crash in GameActivity
fix selection when typing with hardware keyboard
fix tests for GameTextInput
fix text deletion in GameTextInput
Fix various input issues
GameInputText: code refactoring
GameTextInput: Handle IME_ACTION_UNSPECIFIED editor action as 'Enter'
GameTextInput: Prevent keyboard input after GameActivity_hideSoftInput
implement tests for GameTextInput
make android_app_write_cmd() publicly available
make GameTextInput use default implementations from BaseInputConnection
optimize touch events handling by GameActivity
Pass up-to-date locale data to the native code
populate list of ignored characters in InputConnection
provide an ability to override the creation of the SurfaceView instance
refactor GameActivity and GameTextInput interfaces
Reformat GameTextInput sources
Replace Log.wtf with Log.d
Samsung keyboard fix
send explicit signals on key and touch events to the Looper
update default_motion_filter()
update game-activity and game-text-input to 3.1.0alpha01
Update library versions for jetpad
update targetSdkVersion to 35 in all projects
Use int64_t instead of long for historicalEventTimes to avoid overrun on 32bit systems
Use temporal listener variable in InputConnection to prevent race conditions

One update: update default_motion_filter()

is the same fix I PR'd here:

@jb55
Copy link
Author

jb55 commented Mar 13, 2025

@MarijnS95
Copy link
Member

I do wonder if it'd be easier to keep a fork of gamesdk and apply out patches there. Then we can use this as a submodule inside this crate.

@jb55
Copy link
Author

jb55 commented Mar 13, 2025

would definitely make rebasing easier because it was kind of a PITA to fix all the paths on the patches

@MarijnS95
Copy link
Member

There should be an arg to automate stripping the paths, but yeah it's extra confusing (especially the commit history here!) to first revert all the patches, then copy the new code, and finally reapply. I would hate to have to redo that for every release, instead we can just have rebased branches+tags for every upstream release in a fork.

@jb55
Copy link
Author

jb55 commented Mar 13, 2025

downside is that a depth1 clone of gamesdk is like 175MB

@jb55
Copy link
Author

jb55 commented Mar 13, 2025

If we do want to eventually do this I pushed v4.0.0 with our patches here:

https://github.com/jb55/android-games-sdk-rs/tree/android-activity-4.0.0

@jb55
Copy link
Author

jb55 commented Mar 13, 2025

I also squashes a few of the the patches and made them more logically separated:

jb55/android-games-sdk-rs@v4.0.0...android-activity-4.0.0

the support InputAvailable events and fix deadlocks in java callbacks after app destroyed changes had some overlap in logic. They are cleanly separated now.

maybe fix deadlocks in java callbacks after app destroyed could be upstreamed ?

@rib
Copy link
Member

rib commented Mar 14, 2025

Although I'm initially sceptical of using git submodules, I agree it could be good to improve the workflow for maintaining our patches based on an upstream games-sdk branch instead of having to manually re-cherry-pick our in-tree changes to game-activity-csrc.

A workflow where we rebase patches on an upstream branch and then just import a snapshot of the game-activity source that we need (with clear references to the branch we've imported from) could be practical enough without needing to introduce a dependency on submodules.

Maybe we can stream line that a little with some build.rs tweaks that make it easy to build against some out-of-tree branch instead of the game-activity-csrc directory when working on this kind of update to new versions of GameActivity.

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