summaryrefslogtreecommitdiff
path: root/src/android/app
diff options
context:
space:
mode:
authorZephyron <zephyron@citron-emu.org>2025-02-09 15:44:43 +1000
committerMike Lothian <mike@fireburn.co.uk>2025-05-11 16:24:40 +0100
commitd2a0de0cef7e49a83be0c1763f758709dc99d711 (patch)
tree1bc5eafb8b6dbf08372b34fb476610a338d2595b /src/android/app
parent7eb31a0157e73ff9b711809a59351e02e8aa8820 (diff)
network: Fix 0.0 FPS bug on Android (Part 2)
- Add network interface enumeration support for Android - Implement fallback loopback interface when no interfaces are detected - Add ability to force offline mode on critical network errors - Improve socket initialization with better error handling - Add socket state tracking (domain, type, protocol) - Make translation functions static and mark as maybe_unused - Add detailed logging for network initialization failures Part 2 of the Android FPS bug fix focuses on network resilience, particularly handling cases where network initialization fails. Instead of hanging the emulator, it now gracefully falls back to offline mode and provides better diagnostic information.
Diffstat (limited to 'src/android/app')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt
index 02a20dacf..6a2963caa 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/NativeLibrary.kt
@@ -21,6 +21,7 @@ import org.yuzu.yuzu_emu.utils.Log
import org.yuzu.yuzu_emu.model.InstallResult
import org.yuzu.yuzu_emu.model.Patch
import org.yuzu.yuzu_emu.model.GameVerificationResult
+import java.net.NetworkInterface
/**
* Class which contains methods that interact
@@ -459,4 +460,29 @@ object NativeLibrary {
* Checks if all necessary keys are present for decryption
*/
external fun areKeysPresent(): Boolean
+
+ fun getNetworkInterfaces(): Array<String> {
+ val interfaceList = mutableListOf<String>()
+ try {
+ NetworkInterface.getNetworkInterfaces()?.toList()?.forEach { iface ->
+ if (iface.isUp && !iface.isLoopback) {
+ iface.inetAddresses.toList()
+ .filterNot { it.isLoopbackAddress }
+ .forEach { addr ->
+ interfaceList.add("${iface.name};${addr.hostAddress}")
+ }
+ }
+ }
+ } catch (e: Exception) {
+ Log.error("[NativeLibrary] Failed to enumerate network interfaces: ${e.message}")
+ }
+
+ // Always ensure we have at least a loopback interface
+ if (interfaceList.isEmpty()) {
+ Log.warning("[NativeLibrary] No interfaces found, adding loopback fallback")
+ interfaceList.add("lo;127.0.0.1")
+ }
+
+ return interfaceList.toTypedArray()
+ }
}