Skip to content

enhancement(android): port native benchmark runner and recorder #22

@markm39

Description

@markm39

Why

The example currently hides the benchmark screen on Android because the native benchmark runner and manual recorder exist only on the iOS bridge. That makes Android performance work harder to measure and blocks true iOS/Android parity for the example harness.

Current state

On feat/android-parity:

  • Android drawing is usable enough for manual testing.
  • Android eraser responsiveness has improved.
  • The example hides benchmark controls on Android so users do not hit unavailable native methods.
  • iOS still has runBenchmark, startBenchmarkRecording, and stopBenchmarkRecording through MobileInkCanvasViewManager / MobileInkBridge.

Goal

Implement Android equivalents for the iOS native benchmark APIs exposed by NativeInkCanvasRef:

  • runBenchmark(options)
  • startBenchmarkRecording(options)
  • stopBenchmarkRecording()

The output shape should match NativeInkBenchmarkResult so BenchmarkScreen.tsx, ContinuousEnginePool, and InfiniteInkCanvas can run the same code on both platforms.

Useful files

  • src/NativeInkCanvas.tsx
  • src/benchmark/types.ts
  • src/benchmark/aggregate.ts
  • example/BenchmarkScreen.tsx
  • ios/MobileInkModule/MobileInkCanvasView+Benchmark.swift
  • android/src/main/java/com/mathnotes/mobileink/MobileInkCanvasView.kt
  • android/src/main/java/com/mathnotes/mobileink/MobileInkModule.kt
  • android/src/main/cpp/jni_bridge.cpp

Suggested approach

  • Mirror the iOS benchmark result schema first, even if Android internals differ.
  • Prefer native timing around actual Android render/input paths rather than JS-only timing.
  • Keep manual recording and replayed synthetic benchmark support separate if that simplifies the first PR.
  • Once Android methods exist, remove the Android gating in example/App.tsx so the benchmark screen appears on both platforms.

Done when

  • Android exposes the same benchmark methods as iOS through NativeInkCanvasRef.
  • The example benchmark screen works on Android.
  • npm run typecheck, Android export, and Android debug assemble pass.
  • A device/emulator run can produce benchmark JSON for at least one drawing scenario.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is neededperformancePerformance or responsiveness improvements

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions