Skip to content

perf(example): align RN throughput optimizations with NativePHP - #4

Draft
mrousavy wants to merge 2 commits into
bench/flash-throughputfrom
codex/bench-native-parity
Draft

mrousavy wants to merge 2 commits into
bench/flash-throughputfrom
codex/bench-native-parity

Conversation

@mrousavy

@mrousavy mrousavy commented Sep 16, 2026

Copy link
Copy Markdown
Member

The React Native throughput benchmark currently reports each QR through the RN UI thread and fetch, starts its clock before the first confirmed scan, and leaves its camera resolution/FPS implicit. NativePHP PR #3 optimizes those parts on the other side of the comparison.

This companion PR targets bench/flash-throughput and brings those optimizations to the RN example:

  • Native persistent HTTP reporting directly from the VisionCamera frame worklet, with native deduplication, acknowledgement counting and monotonic timing. React polls progress; it does not drive the scan loop or clock.
  • A fresh native HTTP client and camera/scanner session for each run, with untimed HTTP warm-up. Timing starts at the first accepted scan and ends at confirmation 1000, matching Match the React Native throughput path with PHP #3's 999 timed intervals.
  • Android 640×480 and iOS 1280×720 frame targets, a 60 FPS session target, and the corresponding iOS 1/250 s automatic-exposure cap, continuous/near autofocus and disabled smooth autofocus where supported.
  • Stable scanner options, frame disposal on errors, cancellation on navigation/backgrounding, visible request failures, and retained resolved-camera diagnostics.

The native helper is private to the example app. Production ZXing APIs and decoder behavior are unchanged. apps/example/THROUGHPUT.md describes the exact protocol, settings and remaining differences.

This aligns the optimization opportunities; it does not claim measured speedup or perfect framework isolation. Camera fallback rules, native transports, reader options and the display/camera loop still differ. In particular, requested 60 FPS is not proof of delivered 60 FPS. Keep this draft until paired release runs verify the actual camera settings on the same phone.

Validation:

  • Library TypeScript build/typecheck, example typecheck, targeted Biome, Swift formatting and ktlint pass.
  • Nitrogen 0.37.0 generated the committed bindings. CocoaPods installed with the repo's pinned 1.16.2.
  • Android arm64 release APK builds successfully.
  • Unsigned iOS arm64 release build succeeds on Xcode 27. Local validation overrides the deployment target to iOS 16 because Xcode 27 rejects old deployment targets in existing third-party privacy bundles.
  • Local builds used a temporary Metro config with Watchman disabled because the host Watchman service stalled. That machine-specific config is not part of this PR.
  • A local loopback test of the production Swift reporter (using stand-ins for Nitro types) passed first-ack timing, duplicate suppression, rejected-code handling, exact-target completion, frozen results, cancellation, malformed JSON, HTTP errors and connection loss. The server verified one reused TCP connection across warm-up/reports and one POST for 100 submissions of the same value. This test does not exercise the RN bindings or camera.

Pending: actual-camera/runtime testing and paired RN/NativePHP release runs on the same physical phone. No performance improvement is asserted without those measurements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant