React NativeIMEMindloft

Pivoting Mindloft Mobile to React Native 0.82: iOS 27.2 Crashes, Android Keyboards, and IME Boundaries

Why Mindloft abandoned WebView wrapping on mobile for bare React Native 0.82.1, why shrinking the desktop canvas fails on phones, surviving three builds for iOS 27.2 Scene lifecycle crashes, and building a blur/onEndEditing barrier for Android CJK IMEs.

Early mobile builds of Mindloft (formerly Brainlet / 枝间) tried wrapping the WebView canvas with a handful of native UIKit bars and dialogs. The moment you actually edited nodes on a phone, focus handoffs, swipe-back gestures, and soft-keyboard transitions gave the game away.

On November 6 we spun up an isolated prototype in apps/mobile/native-lab (app.ramilo.mobile.lab, commit 847cf50a) with one rule: library, navigation, mindmap/outline, node editing, document title, note inspector, and errors must all render as native React Native components—zero HTML or WebView in visible UI. Loro/WASM math stayed in an invisible headless WebView bridge for now, feeding DTOs and real async save results to the UI.

Instead of chasing the latest 0.88 release, we locked bare React Native 0.82.1 + CLI 20.2.0: OpenHarmony’s out-of-tree ohos_react_native (RNOH) matrix marked 0.82-stable as its primary stable line (0.84 and 0.86 were still RC), and 0.82 mandates the New Architecture (Fabric/TurboModules) from day one.

Why mobile could not just shrink the desktop canvas

Desktop’s web shell later hit its own focus trap in v0.2.2—where position: static on .ai-header let a Tauri drag overlay swallow clicks while inert and aria-modal="true" broke Escape—and scaling that responsive desktop layout down to a phone fails for three structural reasons:

  1. Multi-row toolbars starve the keyboard viewport: We compared “compact library → full-screen canvas + outline toggle” against “outline-first → branch focus”, picked the canvas-first flow, set a 48dp minimum hit target (44pt iOS / 48dp Android), and hid the entire bottom bar during editing so the screen belongs to the active TextInput and Done button.
  2. Fixed node boxes silently truncate titles: Desktop columns assume predictable horizontal space. On mobile, v1’s 96pt cards clipped right edges; v2’s MAP_LAYOUT (164×64 base, 36 parent-child gap, 24 sibling gap) replaced clipping with silent ... truncation; v3 dropped fixed heights for live onLayout measurement keyed by (id, title, note, width, fontScale) (remounting back down to 64 when text shrinks) and replaced 1.2:1 decorative borders with textSecondary connectors (4.94:1 light, 8.56:1 dark).
  3. Sub-pixel layout feedback traps the UI thread: After fixing dynamic heights in v3, Android gfxinfo logged 9,694 frames at 65.7% jank with zero user input, blocking uiautomator idle detection—caused by integer-dp ceiling rounding, selection borders altering content width, and unclamped scrollTo loops. Moving selection rings to absolute overlays, clamping scroll targets, and adding a 1px tolerance in v4 brought idle rendering down to 436 → 436 frames over 4.45s.

Three builds to survive iOS 27.2 launch

Build 1 ran fine on the iOS 26.5 simulator and crashed on tap on a physical iPhone 14 Plus running iOS 27.2 (reviews/2026-11-06-ios-startup-crash.md):

  • Build 1 (SIGTRAP on main thread): Crash logs stopped at ___UIApplicationEvaluateRuntimeIssueForNoSceneLifecycleAdoption_block_invoke. RN’s legacy AppDelegate window setup lacked a Scene manifest; 26.5 simulators logged a warning, while physical iOS 27.2 aborted on launch.
  • Build 2 (crashed with a different selector): Moving window creation into SceneDelegate (UIWindow(windowScene:)) with a single RN factory and root controller crashed immediately at -[BrainletLab.AppDelegate window]: unrecognized selector inside RCTDeviceInfo interfaceOrientationDidChange—RN 0.82.1 still reads application.delegate.window on activation.
  • Build 3 (0.1.0 (3)): Restored a compatibility window property on AppDelegate.swift pointing to the same UIWindow created by SceneDelegate, cleared by identity on disconnect. Cold launch stayed alive on PID 17841 for ~13 minutes with zero crashes.

We kept the simulator caveats intact too: on the same Build 3, iOS 27.1 Duo passed 5/6 (failing orientation rotation), and a fresh 27.0 simulator timed out on document runtime init (0/1) before passing 1/1 on an independent rerun.

Android API 36 keyboard overlap and CJK IME commit barriers

Android adjustResize turned out not to protect deep child nodes. Coordinate logs in android-v2-flow-failure.keyboard.json caught the IME top edge at y = 1517px while the fifth child’s native TextInput sat at y = 1594–1711px, completely buried under the keyboard.

In v3 (apps/mobile/native-lab/src/presentation/motion.tsx), KeyboardAvoidingView computes actual overlap from windowHeight - coords.screenY (naturally resolving to 0 when legacy adjustResize has already shrunk windowHeight) alongside transparent Modal status bars for matching window coordinates.

Landscape mode hit another trap: Gboard opened its fullscreen extract UI (android-v3-continuation-failure.png), covering the entire app header and Done button. In apps/mobile/native-lab/src/presentation/native-input.tsx, ConfirmedTextInput sets disableFullscreenUI and enforces a native completion barrier:

<TextInput
  {...props}
  disableFullscreenUI
  ref={native}
  onChangeText={value => {
    session.changed(value);
    props.onChangeText?.(value);
  }}
  onBlur={event => {
    session.blurred();
    props.onBlur?.(event);
  }}
  onEndEditing={event => {
    const value = event.nativeEvent.text;
    session.ended(value);
    props.onChangeText?.(value);
    props.onEndEditing?.(event);
  }}
/>

The rule is simple: never guess CJK IME composition boundaries from onChangeText (which emits interim pinyin like 'zhong'). Pressing Done calls blur() and awaits native onEndEditing (2000ms timeout, with an 80ms post-blur fallback covered in native-input.test.ts).

Two boundaries remain explicitly open: the first Android v4 QA pass recorded one unlocalized leading-character drop (Android adapter retry 020921 read back as ndroid adapter retry 020921, while three independent reruns matched), and real physical-device Chinese pinyin marked-text composition remains untested on both iOS and Android.

✦

Comments

  • Loading…

Comments are reviewed before publishing; email is visible only to me.