We just about get away with using a StateFlow in NetplaySession since the host sends AbortGameDigest when closing their own dialog. Without that it would be harder for the UI to distinguish between subsequent dialogs. If that wasn't the case then NetplaySession might need to expose the individual progress and result updates and have the view model assemble it into the overall GameDigestProgress.
Create a new NetplaySession each time we try to join a netplay game. Hold onto it in NetplayManager so its available to the different activities that need to access it. Close the session when backing out of the netplay UI. Some guardrails in case things go out of sync: creating a session closes the old one if it is still around for some reason, finalizer in NetplaySession to release native resources if not closed explicitly for some reason. Profiling done to ensure all kotlin and native objects are successfully cleared / garbage collected.
An orientation change can trigger this code path immediately when a game starts. e.g. dolphin is portrait when launching the game but settings force gameplay to landscape. We want to avoid this and continue to the netplay launch code below.
If the user backgrounds dolphin during netplay and then resumes after the process has died it will actually resume from the save state in single player mode, not sure if thats good or bad but fine for now.
Netplay doesnt handle rotation very well, seems to go more and more out of sync the more rotations.
Boot session data is already handled when the game is booted so this is just fallback in case the game launch fails in some weird way.
Add missing @Keep annotations to functions called from C++
Now with cancel button and an actual progress bar. For simplicity, we do
two passes on the progress bar, one for loading the NAND into memory and
one for extracting it. The user directory is likely on an SSD, making
the extraction pass invisibly fast.
The following settings were excluded:
* Port 1-4 ROM: We're only supporting Game Boy Player for now
* Save in Same Directory as the ROM: Implementation nightmare due to SAF
Override AGP-bundled R8 in settings.gradle.kts:
- classpath("com.android.tools:r8:9.1.34") from r8-releases/raw
This resolves :app:minifyReleaseWithR8 failing with:
java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 0
Bug report: https://issuetracker.google.com/issues/495458806
Co-Authored-By: OatmealDome <julian@oatmealdome.me>