From 256ce21522bfaadba7815025bc7046122ee2cfe5 Mon Sep 17 00:00:00 2001 From: gsinghpal Date: Sat, 25 Apr 2026 13:56:47 -0400 Subject: [PATCH] fix(shopfloor): use ZXing's actual API (decodeFromVideoElementContinuously) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous patch called reader.decodeFromCanvas which doesn't exist in @zxing/library 0.21.3. Real methods (verified by grep on the vendored bundle) are: decodeFromVideoElement(el) -- one-shot decodeFromVideoElementContinuously(el, cb) -- continuous loop Switched to the continuous variant. ZXing manages its own per-frame timing internally — we just register the (result, err) callback and React to result.getText() on hits. NotFoundException = no QR this frame, which we silently ignore. Also fixed the related video-play race: ZXing internally registers a 'playing' event listener on the video and then calls play() itself. If we await v.play() ourselves first, the 'playing' event fires BEFORE ZXing attaches its listener and ZXing then waits forever for an event that already happened. Fix: for the zxing path we set attributes + srcObject but do NOT call play(). ZXing's playVideoOnLoadAsync handles play -> playing -> decode in the right order. The native and jsQR paths still pre-play because their loops poll the video themselves. Cleanup: _stopCamera now calls reader.reset() to tear down ZXing's internal state cleanly when the modal closes. Version: shopfloor 19.0.22 -> 19.0.23. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../fusion_plating_shopfloor/__manifest__.py | 2 +- .../static/src/js/qr_scanner.js | 187 ++++++++++-------- 2 files changed, 107 insertions(+), 82 deletions(-) diff --git a/fusion_plating/fusion_plating_shopfloor/__manifest__.py b/fusion_plating/fusion_plating_shopfloor/__manifest__.py index eec5abf7..301d8312 100644 --- a/fusion_plating/fusion_plating_shopfloor/__manifest__.py +++ b/fusion_plating/fusion_plating_shopfloor/__manifest__.py @@ -5,7 +5,7 @@ { 'name': 'Fusion Plating — Shop Floor', - 'version': '19.0.22.0.0', + 'version': '19.0.23.0.0', 'category': 'Manufacturing/Plating', 'summary': 'Shop-floor tablet stations, QR scanning, bake window enforcer, ' 'first-piece inspection gates.', diff --git a/fusion_plating/fusion_plating_shopfloor/static/src/js/qr_scanner.js b/fusion_plating/fusion_plating_shopfloor/static/src/js/qr_scanner.js index 118ec910..e68b1b4b 100644 --- a/fusion_plating/fusion_plating_shopfloor/static/src/js/qr_scanner.js +++ b/fusion_plating/fusion_plating_shopfloor/static/src/js/qr_scanner.js @@ -144,20 +144,37 @@ export class QrScanner extends Component { // Wait one paint tick so the t-ref resolves to the