Fix Android native library loading and missing JNI export - #79
Conversation
…g JNI export.
- Add `global::Java.Lang.System.LoadLibrary("osu.Android.Native")` to `OsuGameActivity.OnCreate` to ensure `JNI_OnLoad` is called, which initializes `g_vm` required by `VulkanRenderer` and potentially internal Oboe JNI usage.
- Add `Java_osu_Android_Native_OboeAudio_nOboeStop` JNI export to `osu.Android/Native/oboe_audio.cpp` to prevent `UnsatisfiedLinkError` if the method is resolved via JNI.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
…g JNI export.
- Add `global::Java.Lang.System.LoadLibrary("osu.Android.Native")` to `OsuGameActivity.OnCreate` to ensure `JNI_OnLoad` is called, which initializes `g_vm` required by `VulkanRenderer` and potentially internal Oboe JNI usage.
- Add `Java_osu_Android_Native_OboeAudio_nOboeStop` JNI export to `osu.Android/Native/oboe_audio.cpp` to prevent `UnsatisfiedLinkError` if the method is resolved via JNI.
…enderer.
- Add `global::Java.Lang.System.LoadLibrary("osu.Android.Native")` to `OsuGameActivity.OnCreate` to ensure `JNI_OnLoad` is called, preventing immediate `UnsatisfiedLinkError` and initializing `g_vm`.
- Add `Java_osu_Android_Native_OboeAudio_nOboeStop` JNI export to `osu.Android/Native/oboe_audio.cpp` to prevent runtime crashes if `OboeAudio.Stop` is called.
- Add thread locking (`disposeLock`) to `osu.Android/Native/VulkanRenderer.cs` in `Render` and `Dispose` to prevent use-after-free race conditions.
…enderer.
- Add `global::Java.Lang.JavaSystem.LoadLibrary("osu.Android.Native")` to `OsuGameActivity.OnCreate` to ensure `JNI_OnLoad` is called, preventing immediate `UnsatisfiedLinkError` and initializing `g_vm`.
- Add `Java_osu_Android_Native_OboeAudio_nOboeStop` JNI export to `osu.Android/Native/oboe_audio.cpp` to prevent runtime crashes if `OboeAudio.Stop` is called.
- Add thread locking (`disposeLock`) to `osu.Android/Native/VulkanRenderer.cs` in `Render` and `Dispose` to prevent use-after-free race conditions.
|
please check errors |
Understood. I have investigated the CI failure and identified that |
- Replace `Java.Lang.System.LoadLibrary` with `Java.Lang.JavaSystem.LoadLibrary` in `OsuGameActivity.cs` to resolve CS0234 error. Xamarin.Android maps `java.lang.System.loadLibrary` to `JavaSystem` to avoid conflict with the .NET `System` namespace.
- Fix flakiness in `TestSceneModPresetColumn.TestEditPresetMod` by checking `IsPresent` for the popover instead of just nullability. This ensures the popover is actually visible and part of the scene graph before interacting with it. - (Previous commit) Fix Android startup crash by correctly loading native library with `JavaSystem.LoadLibrary`.
- Fix flakiness in `TestSceneTimingScreen.TestSelectionDismissedOnUndo` by using a null-conditional operator when checking `timingScreen.SelectedGroup.Value.Time`. This prevents potential NullReferenceExceptions during the wait loop if the selected group is transiently null, ensuring the test retries gracefully until the condition is met.
This PR fixes a crash on Android startup, especially in Release builds, by ensuring the native library is loaded via
System.loadLibrarybefore any native methods are invoked. This guarantees thatJNI_OnLoadis executed, initializing the global JavaVM pointer (g_vm) which is critical forVulkanRendererand other native components that interact with the JNI environment.Additionally, it adds a missing JNI export for
nOboeStoptooboe_audio.cppto align with the other exported methods and prevent potential linker errors if the method is accessed via JNI reflection or other mechanisms.These changes address the user-reported crash on Android.
PR created automatically by Jules for task 4658107465672926237 started by @winnerspiros