summaryrefslogtreecommitdiff
path: root/Source/Android/jni/MainAndroid.cpp
diff options
context:
space:
mode:
authorTom Pratt <tom.pratt@outlook.com>2026-05-12 11:20:01 -0700
committerTom Pratt <tompratt@squareup.com>2026-05-19 12:02:58 +0200
commitabd324e98d735d836d8131cef91b58f3278bc6fa (patch)
treed32b98f84035c45fed4a1ba65d67895ca8272511 /Source/Android/jni/MainAndroid.cpp
parent183d6d778ca8a87dd5ad1ae3513f7fcfd561369d (diff)
Make NetplaySession not a singleton
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.
Diffstat (limited to 'Source/Android/jni/MainAndroid.cpp')
-rw-r--r--Source/Android/jni/MainAndroid.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/Source/Android/jni/MainAndroid.cpp b/Source/Android/jni/MainAndroid.cpp
index 13471a6cd0..0d29ad3908 100644
--- a/Source/Android/jni/MainAndroid.cpp
+++ b/Source/Android/jni/MainAndroid.cpp
@@ -618,10 +618,10 @@ Java_org_dolphinemu_dolphinemu_NativeLibrary_Run___3Ljava_lang_String_2ZLjava_la
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_RunNetPlay(
- JNIEnv* env, jclass, jobjectArray jPaths, jboolean jRiivolution)
+ JNIEnv* env, jclass, jobjectArray jPaths, jboolean jRiivolution, jlong jBootSessionData)
{
- auto boot_session_data = std::unique_ptr<BootSessionData>(reinterpret_cast<BootSessionData*>(
- env->GetStaticLongField(IDCache::GetNetplayClass(), IDCache::GetNetplayBootSessionDataPointer())));
+ auto boot_session_data = std::unique_ptr<BootSessionData>(
+ reinterpret_cast<BootSessionData*>(jBootSessionData));
if (!boot_session_data)
{
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), IDCache::GetDisplayToastMsg(),
@@ -629,7 +629,6 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_RunNetPlay(
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), IDCache::GetFinishEmulationActivity());
return;
}
- env->SetStaticLongField(IDCache::GetNetplayClass(), IDCache::GetNetplayBootSessionDataPointer(), 0);
Run(env, JStringArrayToVector(env, jPaths), jRiivolution, std::move(*boot_session_data));
}