Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion osu.Android/Native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,20 @@ set(CMAKE_C_FLAGS_RELEASE "-O3 -flto=thin -ffast-math -ffunction-sections -fda
# -Wl,-z,max-page-size=16384: align ELF LOAD segments to 16 KB for Android 15+
# devices with 16 KB page sizes. Without this, the .so will fail to load on
# such devices. NDK r28+ supports this flag.
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "-Wl,--gc-sections -Wl,-z,max-page-size=16384 -s")
#
# IMPORTANT: do NOT pass `-s` (or `-Wl,-s`) here. Stripping the native library
# removes the symbol table, which means Android tombstones — and crash-report
# tools like Crash Log Viewer that read them — print only `pc=<hex>` with no
# function name. That makes the SDLThread / audio-thread SIGSEGVs we have been
# chasing essentially unfixable from a tombstone alone, because we cannot tell
# whether the null indirect call originated in our `OboeBridge::onAudioReady`,
# in Oboe itself, in libvulkan, or in the renderer. Keeping symbols costs only
# a few hundred KB in the on-device .so (and zero APK download size when LZ4
# assembly compression is on, since the .so is also compressed), and it is the
# single highest-leverage change we can make for diagnosing real-device crashes.
# `-Wl,--gc-sections` still removes unreferenced sections; only the symbol
# *names* are retained.
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "-Wl,--gc-sections -Wl,-z,max-page-size=16384")

# Disable Oboe's flowgraph module — we don't use any audio processing/conversion
# features (our bridge outputs silence for latency measurement only).
Expand Down Expand Up @@ -64,10 +77,15 @@ set(OBOE_LIB oboe)
find_library(vulkan-lib vulkan REQUIRED)
find_library(log-lib log REQUIRED)
find_library(android-lib android REQUIRED)
# `dl` is needed for dladdr() in crash_handler.cpp (symbol resolution from PCs).
# It is normally auto-linked on Android, but make the dependency explicit so we
# don't accidentally lose dladdr if the toolchain default ever changes.
find_library(dl-lib dl REQUIRED)

add_library(osu_native SHARED
oboe_bridge.cpp
vulkan_bridge.cpp
crash_handler.cpp
)


Expand All @@ -76,4 +94,5 @@ target_link_libraries(osu_native
${vulkan-lib}
${log-lib}
${android-lib}
${dl-lib}
)
1 change: 1 addition & 0 deletions osu.Android/Native/OboeAudioBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,6 @@ public void Dispose()
[DllImport(lib_name)] internal static extern void nADPFReportActualDuration(IntPtr sessionPtr, long actualDurationNanos);
[DllImport(lib_name)] internal static extern void nADPFUpdateTargetDuration(IntPtr sessionPtr, long targetDurationNanos);
[DllImport(lib_name)] internal static extern void nADPFCloseSession(IntPtr sessionPtr);
[DllImport(lib_name)] internal static extern void nInstallCrashHandler([MarshalAs(UnmanagedType.LPUTF8Str)] string? logPath);
}
}
Loading
Loading