V0.4.0加入锁定二维码

This commit is contained in:
zhy
2026-08-10 17:09:30 +08:00
parent d885259e2b
commit 241e22abea
34 changed files with 1754 additions and 985 deletions
+158 -138
View File
@@ -1,182 +1,202 @@
# QFT v0.3.0-rc3 test report
# QFT v0.4.0-rc2 test report
Date: 2026-08-10
This report deliberately separates **tests actually executed in the current build environment** from **hardware acceptance that cannot be truthfully simulated here**.
This report separates **tests actually executed in the current environment** from **physical hardware acceptance that cannot be simulated here**.
## What this RC changes
The rc2 optical path is deliberately simpler than v0.3:
- 2×2 / 4-channel QR removed;
- one large QR only;
- QFT2 + Base45 text layer;
- 450-byte DATA payload;
- Android 640×480 analysis;
- centered acquisition → finder-point ROI lock → progressive expansion → reacquire;
- reusable Y-plane buffer;
- GlobalHistogram fast hot path with sparse Hybrid fallback;
- duplicate displayed frames suppressed before the file assembler;
- dynamic lock overlay and movement-triggered AF/AE;
- Windows draggable split pane / focus-QR mode.
Android→Windows QFTPAIR2/discovery/parallel upload remains and is regression-tested.
## Executed and passed
### Optical protocol recovery
### 1. QFT2 optical loss recovery — PASS
Command:
`python scripts/protocol_selftest.py`
```text
python scripts/protocol_selftest.py
```
Representative result from the final source:
```text
PASS QFT2/Base45 single-QR: 1200123 bytes, 2667 chunks,
22% frame loss, recovered in 6 rounds; QR-L v15 vs legacy Base64 v18,
12px/module@1024, text=722 chars, theoretical payload=26.4 KiB/s
```
Verified:
- Base45 known vectors;
- QFT2 magic/version/header;
- CRC32;
- 450 B DATA chunks;
- continuous replay after 22% synthetic whole-frame loss;
- exact file reconstruction;
- final SHA-256 equality;
- representative QFT2 QR density below the old QFT1/Base64 comparison.
Theoretical payload is `450 × 60 = 27,000 B/s`; it is not a claim of physical camera throughput.
### 2. Synthetic camera-frame decode and ROI — PASS
Command:
```text
python scripts/optical_image_decode_selftest.py
```
The test renders a 722-character QFT2/Base45 QR-L v15, places it into a 640×480 grayscale camera-like frame, applies 3° rotation and light Gaussian blur, then decodes both the full frame and a representative locked crop.
Typical final runs were approximately:
```text
full frame ≈ 4.2–4.7 ms/decode
locked ROI ≈ 2.8–2.9 ms/decode
ROI area ≈ 45–46% of frame
```
Both paths returned the exact QFT2 text. Timing varies by host and decoder cache state; this is a host-side directional benchmark, **not Android CameraX FPS**.
### 3. Single-channel / Android static guards — PASS
Commands:
```text
python scripts/android_compat_selftest.py
python scripts/single_channel_guard_selftest.py
```
Verified in the final source:
- `minSdk = 24`;
- no 2×2/4-lane Windows optical sender path;
- no four-reader Android optical decoder path;
- one large QFT2/Base45 QR;
- 450 B default DATA payload;
- 640×480 ImageAnalysis;
- `STRATEGY_KEEP_ONLY_LATEST`;
- Camera2Interop AE FPS request + no-explicit-FPS fallback when OEM binding rejects it;
- `QRCodeReader` only;
- ROI-only locked Y copy;
- grow-only reusable luma scratch buffer;
- lock smoothing / dynamic overlay / lock-centered refocus;
- QFT2/Base45 parsing + QFT1 legacy parsing;
- Android 7~9 and Android 10+ Wi-Fi branches;
- no `java.util.Base64` dependency in app source.
### 4. Host Kotlin QFT2/ROI runtime — PASS
`kotlin_host_smoke.py` compiled and executed the actual final:
- `Base45.kt`;
- `Base64Url.kt`;
- `Protocol.kt`;
- `LockRect.kt`.
Result:
- 2,500,123-byte random file
- 900-byte chunks
- 4 QR/page
- target 60 pages/s model
- synthetic 24% whole-page loss + 14% per-lane QR loss
- reconstructed exact original file in 9 rounds
- final SHA-256 identical
- representative frame: QR v25, ~3 rendered pixels/module at native 960px page
- theoretical raw file payload: ~210.9 KiB/s
```text
PASS Kotlin QFT2/Base45 protocol + ROI lock smoothing
```
**PASS**
This test caught and fixed an earlier Kotlin expression-body compile error in `QftProtocol.parseText()` before packaging.
### Synthetic visual QR decode
### 5. Host Kotlin QrAnalyzer compile smoke — PASS
Command:
`python scripts/optical_image_decode_selftest.py`
Result in this environment:
- 4/4 high-density QFT optical QR symbols decoded from one 960×960 synthetic page using libzbar/pyzbar
- QFTPAIR2 QR-M decoded after synthetic 7° rotation plus light Gaussian blur
**PASS**
This proves generated QR geometry/data is decodable under a synthetic image path; it does **not** prove a particular monitor/camera can decode 60 physical refreshes per second.
### QFTPAIR2 size / QR density
Command:
`python scripts/pairing_selftest.py`
The same test compiles the final `QrAnalyzer.kt`, `GrayFrame.kt`, `LockRect.kt` and `ScannerLockState.kt` against minimal CameraX/ZXing-shaped JVM stubs.
Result:
- QFTPAIR2: 207 characters with one Direct-AP endpoint hint
- older QFTPAIR1 comparison: 368 characters
- v2 size: 56.2% of v1
- medium-error-correction QR: version 10
- encode/decode round-trip exact
```text
PASS Kotlin QrAnalyzer compile smoke with CameraX/ZXing-shaped stubs
```
**PASS**
This checks Kotlin type/signature consistency of the ROI scanner without claiming it replaces a real Android SDK build.
### Parallel local-file chunk reconstruction
### 6. Android→Windows regression tests — PASS
Command:
`run_all_selftests.py` also passed:
`python scripts/parallel_upload_selftest.py`
- QFTPAIR2: 207 chars vs old 368-char test payload, QR-M v10 in the model;
- UDP discovery request/response token + port round trip;
- 8-worker parallel reconstruction of ~64 MiB;
- 8 MiB chunks / 1 MiB worker I/O;
- loopback UDP discovery + authenticated HTTP + out-of-order chunk upload;
- ~40 MiB final reconstruction with identical SHA-256.
Result:
### 7. Memory budget model — PASS
- ~64 MiB random file
- 8 MiB test chunks
- 8 worker threads
- 1 MiB worker I/O buffers
- out-of-order positioned writes
- final SHA-256 identical
The guard models the Windows single-QR 1024×1024 RGBA pre-render queue:
**PASS**
```text
192 frames × ~4 MiB = 768 MiB managed cache
+ 96 MiB transient allowance
< 1100 MiB design ceiling
```
### End-to-end local protocol integration
This is a design-budget check, not an OS-enforced RSS hard cap. GPU/runtime allocators can add platform-specific memory.
Command:
## Important implementation decisions validated during rc2
`python scripts/local_transfer_integration_selftest.py`
### QFT2 uses Result.text, not ZXing rawBytes
Result:
The active path is Base45 text. Android reconstructs the QFT binary frame from `Result.text`. The code does not depend on ZXing `Result.rawBytes` representing the original byte-mode payload.
- QFTDISC2 UDP request/response
- session-token authenticated `/qft/ping`
- Parallel-v2 init
- out-of-order chunk POSTs using 8 workers
- finish
- exact reconstructed file and SHA-256 match
### Duplicate camera hits are not duplicate assembler work
**PASS**
At 45/60 display FPS, a camera can observe the same displayed QR in multiple exposures. rc2 still counts every successful decode in diagnostics, but only a changed QFT2 text fingerprint is delivered to `SessionAssembler`.
### Standalone UDP discovery
### AF/AE does not run on a fixed periodic timer
Command:
The scanner performs initial focus/metering, then re-meters after first lock or material ROI movement. A stationary locked QR does not force AF/AE every few seconds, reducing focus-pumping risk.
`python scripts/udp_discovery_selftest.py`
## Not executable in this environment
QFTDISC2 / QFTHERE2 token and port round-trip.
The current generation environment does not contain the Windows MSVC Rust toolchain, Android SDK, a physical Android camera, a Windows display or a Windows Wi-Fi Direct adapter. Therefore the following are **not claimed as passed here**:
**PASS**
1. Windows `cargo check/test/build --release` for rc2.
2. Android Gradle `:app:testDebugUnitTest :app:assembleDebug` against the real Android SDK.
3. Actual 30/45/60 displayed FPS → CameraX/ZXing effective new-frame throughput.
4. Lock acquisition/reacquisition timing on Android 7 and different phone camera pipelines.
5. PreviewView overlay mapping on every OEM sensor/crop/rotation combination.
6. Real Windows QFT Direct adapter / driver / firewall behavior.
### Memory-budget model
The package remains an **RC** until those physical checks pass.
Command:
## Required physical acceptance
`python scripts/memory_budget_selftest.py`
Run:
Result:
```powershell
.\VERIFY_WINDOWS_HOST.ps1
```
- 4QR 960px pre-render page ≈ 3.5156 MiB as Color32
- maximum cache page cap 192 → ≈ 675 MiB
- conservative extra transient test allowance remains below the 1100 MiB design ceiling
- whole source file is no longer memory-mapped
Then use a small optical file and record Android's UI values at Windows 30, 45 and 60 FPS:
**PASS (design-budget test)**
- camera FPS;
- successful decode/s;
- distinct new-frame/s;
- average decode ms;
- lock area percentage;
- time to first lock;
- time to reacquire after a small phone movement.
This is not an OS-level hard RSS limiter. GPU drivers, allocator fragmentation and platform runtime memory vary; the implementation intentionally leaves several hundred MiB headroom instead of allocating a full 1 GiB cache.
Keep the Windows FPS setting that produces the highest **distinct new-frame/s**, not necessarily the highest display FPS.
### Android compatibility/static guards
Command:
`python scripts/android_compat_selftest.py`
Checked:
- minSdk 24
- API 29 modern/legacy Wi-Fi split
- Android 7~9 storage path
- Android <=12 location permission
- Android 13+ nearby-WiFi permission
- network security config for local HTTP
- gateway/directed-broadcast/subnet discovery fallbacks
- 8-worker upload
- 640×480 pairing scan + 1280×720 optical analysis
- KEEP_ONLY_LATEST
- no full-frame rotate in scanner hot path
- no `java.util.Base64` dependency in main Android source
**PASS**
### Kotlin source checks executed
Using `kotlinc-jvm 1.9.0` plus small Android/JSON stubs where necessary:
- `Base64Url.kt + Protocol.kt` runtime parser test: **PASS**
- `PairingProtocol.kt` syntax/type test: **PASS**
- `UploadClient.kt + PairingProtocol.kt` syntax/type test: **PASS**
- `GrayFrame.kt + QrAnalyzer.kt` syntax/type test: **PASS**
- `WifiConnector.kt` syntax/type test across the modern/legacy branches: **PASS**
These tests caught and fixed an earlier `ExecutorCompletionService.submit<String?>` source error before packaging rc3.
## Not executable in the current Linux build sandbox
The following are hardware/OS-specific and therefore are **not claimed as passed** here:
1. Windows `cargo check/build` against the Windows MSVC/WinRT target.
2. Actual `WiFiDirectAdvertisementPublisher` start on a Windows Wi-Fi adapter.
3. Windows Defender Firewall private-network approval behavior.
4. Android Gradle APK build against a local Android SDK in this sandbox.
5. Android 7/8/9/10/11/12/13/14/15/16+ install/runtime matrix.
6. Real monitor → real camera optical performance at 30/60Hz, different brightness, rolling shutter and autofocus conditions.
7. Real Wi-Fi Direct throughput across different NIC/phone vendors.
For those reasons **v0.3.0-rc3 remains an RC, not a final stable release**.
## Required physical acceptance before marking stable
Run `VERIFY_WINDOWS_HOST.ps1`, then at minimum:
- Windows 10/11 + Android 7/9/10/13/latest available devices.
- Optical files: 10 KiB, 1 MiB, 10 MiB at 30 FPS and 60 FPS.
- Verify Android UI actual camera FPS / QR/s and final SHA-256.
- Android→Windows QFT Direct: first-time pairing, repeat pairing, reconnect after Wi-Fi loss.
- Test with Windows Firewall prompt accepted and with “current LAN” fallback.
- Upload 10 MiB, 500 MiB, and >2 GiB files; verify final SHA-256 and memory usage.
- Observe Windows working set during optical 60 FPS; if host-specific RSS exceeds 1.1 GiB, reduce the pre-encode cache slider (default 384 MiB) and record the device/driver combination.
Only after this matrix is passed should the RC label be removed.
For file correctness, verify 100 KiB, 1 MiB and 10 MiB optical transfers by final SHA-256. For Android→Windows, repeat first-time Direct pairing, second pairing, Wi-Fi reconnect and LAN fallback.