Skip to content

feat(rollup): v0.3.2 Comprehensive Stability Rollup (24 Defect Remediation) - #61

Merged
kvm404 merged 5 commits into
mainfrom
fix/v0.3.2-stability-rollup
Sep 3, 2026
Merged

kvm404 merged 5 commits into
mainfrom
fix/v0.3.2-stability-rollup

Conversation

@kvm404

@kvm404 kvm404 commented Sep 3, 2026 •

Copy link
Copy Markdown
Owner

PR: feat(rollup): v0.3.2 Comprehensive Stability Rollup (24 Defect Remediation)

Summary

This Pull Request resolves all 24 verified architectural and implementation defects documented during the PhoneCam system audit, encompassing memory leaks, concurrency races, protocol desynchronizations, packaging incompatibilities, and denial-of-service edge cases.

All fixes are implemented on branch fix/v0.3.2-stability-rollup and organized into 4 logical atomic commits:

  1. Commit 1 (35c5efe) — Android Media Pipeline & Lifecycle (Workstream A):

    • BUG-01: Close ImageProxy in finally block and query input buffer capacity to prevent GraphicBuffer pool exhaustion and color plane truncations.
    • BUG-02: Trigger startForeground prior to service teardown in onStartCommand and UI stop flows to eliminate Android OS ForegroundServiceDidNotStartInTimeException.
    • BUG-03: Intercept INFO_OUTPUT_FORMAT_CHANGED during drainOutput to cache baseline SPS/PPS parameter sets, ensuring RTP decoders recover from missing keyframe headers.
    • BUG-05: Add src.position() buffer offset in copyPlane to prevent UV chroma plane corruption on devices with interleaved direct byte buffers.
    • BUG-06: Explicitly re-throw IllegalStateException on encoder configuration failure in VideoEncoder.start() instead of swallowing into onError.
    • BUG-07: Centered letterboxing/pillarboxing with YUV black borders (Y=16, U=V=128) in toFrameData when cameras negotiate resolutions below target, eliminating fatal assertions.
    • BUG-08: Release MediaCodec output buffer before RTP packetization and network transmit, wrapping extraction in try ... finally to eliminate encoder starvation, frame latency spikes, and buffer leaks on extraction exceptions.
    • BUG-18: Extend ZoomStepper.shouldShow(minRatio, maxRatio) to detect ultra-wide camera lenses (0.5x–1.0x).
  2. Commit 2 (584b80f) — Linux Daemon & Lifecycle Management (Workstream B):

    • BUG-04: Delegate auto-approval exclusively to control.Server in start.Run to prevent concurrency races that dropped the trust secret; guard external API log output with !config.AutoApprove.
    • BUG-12: Bounded timeout wait (waitReceiverExit) on all exit/error paths in superviseReceiver, preventing orphaned gst-launch-1.0 processes from locking /dev/video10.
    • BUG-13: Introduce stateUnresponsive in lifecycle.check() to preserve session.json on transient HTTP probe timeouts while the PID is alive.
    • BUG-20: Drain sender and receiver channels on timeout or error paths in smoke.Run to prevent process leaks.
    • BUG-21: Default omitted multi-device slots to disabled (enabled: false, found: true) in ExclusiveCapsForDevice when exclusive_caps CSV length is shorter than device index.
  3. Commit 3 (15c287a) — Control Protocol, Session & Reconnect (Workstream C):

    • BUG-09: Replace one-shot credential burning (TakeSecrets) with PeekSecrets, retaining standing credentials until RTP media packets are received from the approved peer.
    • BUG-10: Remove QR TTL expiry checks during operator approval in session.approve() and add clock skew tolerance on Android.
    • BUG-11: Implement POST /leave route in control.Server and dispatch leave requests on Android to reset pairing state (including clearing negotiated video profiles) and permit immediate rescanning without daemon restart.
    • BUG-19: Invalidate active in-memory pairing sessions and clear media allow rules immediately upon deleting a trusted device via DELETE /trust/{id}, checking both approved and pending devices.
  4. Commit 4 (3404161) — Desktop Plugin & Packaging (Workstream D):

    • BUG-14: Add -sSf fail-fast flag to curlArgs and validate !obj.error and required fields (v, control, rtp, session, token, expires) in Model.parsePairing.
    • BUG-15: Abort restart loops in Service.qml:finishStop on non-zero exit codes to avoid binding crashes.
    • BUG-16: Invalidate and reset _lastQrJson cache on daemon stop or QR render error in Service.qml.
    • BUG-17: Update Fedora RPM dependency to akmod-v4l2loopback in packaging/nfpm.yaml and setup.go.
    • BUG-22: Install MIT LICENSE file into ${pkgdir}/usr/share/licenses/${pkgname}/LICENSE in AUR PKGBUILD.
    • BUG-23: Add pre-flight check and warning for qrencode in install.sh and capture stderr in qrProcess.
    • BUG-24: Preserve the first root-cause error line in Service.qml:startProcess.stderr by guarding against subsequent line overwrites.

Commit History

3404161 fix(desktop/pkg): resolve curl error handling, stop races, qr caching, and package dependencies
15c287a fix(protocol): resolve secret retention, token expiry, leave teardown, and revocation defects
584b80f fix(daemon): resolve process lifecycle, device verification, and concurrency defects
35c5efe fix(android): resolve media pipeline, lifecycle, and color space defects

Verification & Testing Matrix

Subsystem Test Command Result Notes
Go Linux Daemon mise exec go@1.22.12 -- go test -v -race -count=1 ./... PASS (100%) All unit, integration, and concurrency race tests passed cleanly across all packages (control, lifecycle, pairing, rtp, session, setup, smoke, start, trust, v4l2).
Android Unit Suite JAVA_HOME=/usr/lib/jvm/java-17-openjdk ./gradlew testDebugUnitTest --rerun-tasks PASS (100%) 25 tasks executed; verified frame conversion with offset positions, letterboxing of undersized resolutions, zoom steppers, and pairing controllers.
Android Debug Assembly JAVA_HOME=/usr/lib/jvm/java-17-openjdk ./gradlew assembleDebug PASS (100%) Full debug APK compiled and assembled cleanly.
Omarchy Desktop Plugin mise exec node@25.2.1 -- node omarchy-plugin/test/model-test.js PASS (100%) All model tests passed, including new assertions for curl fast-fail flags, pairing error payload rejection, missing field rejection, and doctor checks.

Security & Architecture Highlights

  1. Credential Preservation Under Lossy LAN:
    The control protocol previously destroyed resume tokens on a single GET /status read. In lossy wireless environments, dropped HTTP frames resulted in permanent loss of reconnect ability. Secrets are now safely retained until RTP media packets verify successful end-to-end streaming.

  2. Loopback Revocation Isolation:
    Revoking a device via DELETE /trust/{id} now immediately tears down the media firewall rule and resets the active session in memory (for both approved and pending devices), preventing revoked devices from continuing to stream or being approved.

  3. Buffer Management & Graphic Memory Stability:
    MediaCodec input images and output buffers are guaranteed to be closed/released via finally blocks, preventing thread starvation and memory exhaustion in continuous video capture sessions even under buffer underflow/indexing exceptions.

  4. Resource Cleanliness:
    Supervision loops for gst-launch-1.0 and child smoke-test processes now enforce bounded timeouts to reap child processes, completely preventing orphaned locks on /dev/video10.

- Close MediaCodec input image in finally block and query input buffer capacity (BUG-01)
- Ensure startForeground is called before service stop/destroy to avoid watchdog timeout (BUG-02)
- Handle INFO_OUTPUT_FORMAT_CHANGED in drainOutput to extract SPS/PPS parameter sets (BUG-03)
- Respect ByteBuffer position in copyPlane to prevent chroma plane interleaving corruption (BUG-05)
- Propagate configuration failures by throwing in VideoEncoder.start() (BUG-06)
- Handle smaller resolution camera frames with black centering in toFrameData (BUG-07)
- Release MediaCodec output buffer before network transmit to eliminate buffer starvation (BUG-08)
- Support ultra-wide lens ranges in ZoomStepper.shouldShow (BUG-18)
…urrency defects

- Delegate auto-approval exclusively to control.Server in start.Run to eliminate pairing race (BUG-04)
- Wait for receiver process termination with timeout to avoid orphaned gst-launch-1.0 (BUG-12)
- Prevent destructive session file deletion on transient probe timeouts in lifecycle.check (BUG-13)
- Ensure child processes are drained and reaped on smoke test failures and timeouts (BUG-20)
- Handle multi-device exclusive_caps CSV length mismatch in ExclusiveCapsForDevice (BUG-21)
…, and revocation defects

- Retain pairing secrets until RTP media starts instead of one-shot destruction on status poll (BUG-09)
- Eliminate operator approval blocking by QR expiry and add clock skew tolerance (BUG-10)
- Add POST /leave endpoint and client teardown to reset pairing state on leave (BUG-11)
- Invalidate active sessions and reset media allow when trusted device is revoked (BUG-19)
…, and package dependencies

- Add -sSf flag to curlArgs and error rejection in parsePairing (BUG-14)
- Prevent desktop restart into broken state on failed daemon stop in finishStop (BUG-15)
- Invalidate and clear stale QR code cache in qrProcess on daemon restarts (BUG-16)
- Correct Fedora RPM packaging dependency to akmod-v4l2loopback (BUG-17)
- Install MIT license to /usr/share/licenses in AUR PKGBUILD (BUG-22)
- Add pre-flight check and error reporting for missing qrencode binary (BUG-23)
- Preserve root-cause error line in startProcess.stderr SplitParser (BUG-24)
@kvm404
kvm404 force-pushed the fix/v0.3.2-stability-rollup branch from d870ee4 to 3404161 Compare September 3, 2026 13:47
Require loopback, the paired control IP, QR session+token, resume_token,
or pairing_secret before ResetPairing. Random LAN hosts get 403.

Keep WaitingApproval polling after QR TTL (BUG-10) but test 120s clock
skew. Assert letterbox chroma fill/siting. Drop undeclared QML write.
@kvm404
kvm404 merged commit fb7b62c into main Sep 3, 2026
2 checks passed
@kvm404
kvm404 deleted the fix/v0.3.2-stability-rollup branch September 3, 2026 18:15
@kvm404 kvm404 mentioned this pull request Sep 3, 2026
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