From 6e65324f44f06c527348f4400b35a7d9e60a57d3 Mon Sep 17 00:00:00 2001 From: agra Date: Tue, 19 May 2026 23:01:23 +0300 Subject: [PATCH] ffi 1.27: switch safe-insets call site to sx-side JNI implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `AndroidPlatform.safe_insets` now reaches into the JVM through the sx helpers from 1.25 + 1.26 instead of the C `sx_android_query_safe_insets` foreign call: attached := false; env := sx_android_get_env(g_android_activity, @attached); if env != null { clazz := sx_android_activity_clazz(g_android_activity); sx_query_safe_insets_jni(env, clazz, @t, @l, @b, @r); if attached { sx_android_detach_env(g_android_activity); } } Chess Android IR now includes the seven `(@SX_JNI_CLS_*, @SX_JNI_MID_*)` slot pairs (one per unique literal `(name, sig)` pair: getWindow, getDecorView, getRootWindowInsets, getSystemWindowInset{Top,Left, Bottom,Right}). First call populates each; subsequent calls hit the cached jmethodID via the 1.17 lazy-init branch. The C `sx_android_query_safe_insets` body is now unused; left in place per the plan ("leave the file in place until Phase 2 deletes it"). Chess Android + iOS-sim both compile clean; host 118/119; cross-compile 3/3. On-device chess regression is the next checkpoint — the safe-area behavior is visible: board must sit below the status bar with correct top inset on a Pixel 7 Pro with notch. Deferred to the next session (requires APK build + adb install + screencap). --- library/modules/platform/android.sx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/library/modules/platform/android.sx b/library/modules/platform/android.sx index 8e51647..8bd1d17 100644 --- a/library/modules/platform/android.sx +++ b/library/modules/platform/android.sx @@ -390,7 +390,13 @@ impl Platform for AndroidPlatform { // bootstrap is too early. if !self.safe_insets_queried and g_android_activity != null and self.egl_surface != null { t : s32 = 0; l : s32 = 0; b : s32 = 0; r : s32 = 0; - sx_android_query_safe_insets(g_android_activity, @t, @l, @b, @r); + attached : bool = false; + env := sx_android_get_env(g_android_activity, @attached); + if env != null { + clazz := sx_android_activity_clazz(g_android_activity); + sx_query_safe_insets_jni(env, clazz, @t, @l, @b, @r); + if attached { sx_android_detach_env(g_android_activity); } + } inv : f32 = if self.dpi_scale > 0.0 then 1.0 / self.dpi_scale else 1.0; self.safe_top = xx t * inv; self.safe_left = xx l * inv;