Add Android host support (arm64, GDI, Vulkan) - #12
Conversation
Brovan now runs on Android as a third host alongside Windows and Linux. New Brovan android embedding layer. The emulator becomes a NativeAOT shared library driven by a host app rather than a process with a Main: - BrovanAndroidApi - exported C ABI (init, surface, start, input injection, window enumeration, debugger commands). - AndroidWinManager - IDisplayConnection over ANativeWindow, plus IGdiRenderSupport. - AndroidGdiSurface - software rasteriser (lines, rects, ellipses, polygons) into a per-guest-window backbuffer posted via ANativeWindow_lock/ unlockAndPost, white background. - AndroidVulkanWsi and a generator branch - VK_KHR_android_surface instead of Win32/Xcb. - AndroidInput, AndroidLog, AndroidHost, AndroidGuestWindows, JNI shim, Java bindings. - Launcher app: Material 3 library, in-app program import via SAF, settings, on-screen joystick/D-pad/touchpad controls, opt-in developer console wired to the debugger. - build-apk.sh - Unicorn cross-build, linux-bionic-arm64 publish, bundled OpenSSL, APK assembly. Changes to shared emulator code: - Case-insensitive shipped-DLL resolution in GetWindowsLibPath. Import tables say KERNEL32.dll, System32 ships kernel32.dll; broken on any case-sensitive host, and it surfaced as a guest loading zero modules. - GlobalPropertiesToRemove on the generator ProjectReference. Target-shaped properties leaked into the analyzer, csc silently refused to load it (CS8034 is only a warning), and every source generator emitted nothing. - GdiPrimitive.Hwnd. The four EnqueueGdi* helpers already had the guest HWND and dropped it, making per-window compositing impossible. - Program.SplitCommandLine widened to internal for embedders. Windows and Linux behaviour is unchanged; the new paths are gated on the RID or !IsWindows.
|
@claude review |
|
Claude finished @AdvDebug's task in 3m 43s —— View job Review: Android host support (arm64, GDI, Vulkan)
This is a big, well-organized piece of work — the case-sensitivity fix, the Likely blocker: native library resolver never handles Android
if (string.Equals(LibName, "unicorn", StringComparison.OrdinalIgnoreCase))
{
if (GeneralHelper.IsWindows) return NativeLibrary.Load("unicorn.dll", Asm, SearchPath);
if (GeneralHelper.IsLinux) return NativeLibrary.Load("libunicorn.so", Asm, SearchPath);
throw new PlatformNotSupportedException("Brovan currently supports resolving unicorn for Windows and Linux only.");
}
if (string.Equals(LibName, "vulkan-1.dll", StringComparison.OrdinalIgnoreCase) && GeneralHelper.IsLinux)
{
if (NativeLibrary.TryLoad("libvulkan.so.1", out IntPtr handle)) return handle;
if (NativeLibrary.TryLoad("libvulkan.so", out handle)) return handle;
}
The practical effect: on Android, the very first P/Invoke into Since if (string.Equals(LibName, "unicorn", StringComparison.OrdinalIgnoreCase))
{
if (GeneralHelper.IsWindows) return NativeLibrary.Load("unicorn.dll", Asm, SearchPath);
if (GeneralHelper.IsLinux || Brovan.Android.AndroidHost.IsActive) return NativeLibrary.Load("libunicorn.so", Asm, SearchPath);
throw new PlatformNotSupportedException(...);
}
if (string.Equals(LibName, "vulkan-1.dll", StringComparison.OrdinalIgnoreCase) && (GeneralHelper.IsLinux || Brovan.Android.AndroidHost.IsActive))
{
if (NativeLibrary.TryLoad("libvulkan.so.1", out IntPtr handle)) return handle;
if (NativeLibrary.TryLoad("libvulkan.so", out handle)) return handle;
}Worth double-checking on-device (or in CI) that a guest actually runs to confirm this either isn't hit for some reason I'm missing, or gets fixed. Minor / worth a second look
|
|
it worked fine before that and i didn't notice that this was missing in the first place, so it seemed like RuntimeInformation.IsOSPlatform(OSPlatform.Linux) already returned true in android, confirmed it too. so i think it is better to revert that vulkan android check change and just write a summary comment on IsLinux. |
|
It isn't really usable right now because you will have to transfer files using ADB for Registry and libraries, but i will add them soon. |
Brovan now runs on Android as a third host alongside Windows and Linux.
New Brovan android embedding layer. The emulator becomes a NativeAOT shared library driven by a host app rather than a process with a Main:
Changes to shared emulator code: