Repository navigation
Conversation
…tNFT (#75) (#76) * feat(nft): import NFT tracking helpers from jsartoolkitNFT (#75) Copy trackingMod, trackingMod2d, trackingSub, markerDecompress and NFTMarkerState from jsartoolkitNFT/emscripten (master) into WebARKit/WebARKitTrackers/WebARKitNFT. Local includes now use <WebARKitTrackers/WebARKitNFT/...>. No functional changes; build integration and fixes follow in separate commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(nft): make WebARKitNFT helpers build outside emscripten (#75) - rename ar2Tracking2dSub to ar2Tracking2dSubMod: it is public here but static in AR2/tracking2d.c - markerDecompress.c: drop unused <emscripten.h>, use <zlib.h> - markerDecompress.h: add include guard Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(nft): add WEBARKIT_BUILD_NFT CMake option and WebARKitNFT target (#75) - WEBARKIT_BUILD_OPTICAL (ON): the existing OpenCV WebARKitLib target - WEBARKIT_BUILD_NFT (OFF): static WebARKitNFT library with the NFT helpers plus the AR, ARICP, AR2, KPM and ARUtil sources they need (lists mirror jsartoolkitNFT/tools/makem.js); no OpenCV - WEBARKIT_NFT_THREADS (OFF): adds trackingSub and ARUtil/thread_sub Emscripten uses the libjpeg/zlib ports; native builds use find_package. Built with emsdk 4.0.17; linked and smoke-tested with threads on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(nft): return -1 from markerDecompress on errors instead of exit() decompressMarkers() and extractDataAndSave() killed the whole process on a missing or malformed .zft. They now free their buffers and return -1; extractDataAndSave() returns int. Callers in jsartoolkitNFT already ignore the result. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(nft): initialise icpHandle and cparamLT in ar2CreateHandleSubMod The function is public, but left icpHandle uninitialised, so ar2DeleteHandleMod() freed a garbage pointer on a handle made with it directly (segfault on native builds; wasm memory starts zeroed, so it went unnoticed). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(kpm): add missing <limits> and <unordered_map> includes FreakMatcher relied on libc++ pulling them in transitively; GCC 13 (libstdc++) fails without them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(nft): add WebARKitNFT gtest suite and run it in CI (#75) - webarkit_nft_test: markerDecompress (round trip, missing file, malformed data), NFTMarkerState defaults, ar2 handle create/delete, trackingSub worker start/quit - WebARKitNFT also builds the minizip sources file_utils.c needs (crypt, ioapi, unzip, zip), with USE_FILE32API on Emscripten - CI installs zlib1g-dev and runs webarkit_nft_test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: document the WebARKitNFT helpers and CMake options (#75) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(nft): always build ARUtil thread helpers in WebARKitNFT AR2 handle.c and tracking.c call threadInit()/threadStartSignal() whatever WEBARKIT_NFT_THREADS says, so thread_sub.c is now always compiled and native builds always link Threads. The option now only adds trackingSub (and -pthread on Emscripten). Reported by Qodo on #76. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(nft): harden markerDecompress against malformed and large .zft files - check zlib init/inflate results, grow the output buffer past 4 MB and NUL-terminate it before searching it - validate field order and non-empty lengths before writing anything - write marker files in binary mode, check fopen/fwrite/fclose and remove partial output on failure - drop the remove() of the source archive: it built a wrong name and never deleted anything Reported by Qodo on #76. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(nft): guard trackingSub against overlapping scans and failed init - trackingInitStart() returns -1 while the previous search is uncollected, instead of overwriting the image the worker reads - trackingInitInit() checks the image allocation and thread creation and frees everything on failure - tests: >4 MB marker, binary bytes, field order, non-zlib data, source archive kept, start rejected until results are collected Reported by Qodo on #76. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…#77) RAND_MAX + 1.0F converted 2147483647 to float (-Wimplicit-const-int-float-conversion). A double holds RAND_MAX + 1 exactly, and j * rand() no longer loses precision. k stays in [0, j-1]. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
PR Summary by QodoRelease 0.10.0 with standalone NFT helpers and AR2 precision fix
AI Description
Diagram
High-Level Assessment
Files changed (19)
|
Code Review by Qodo
1. A failed extraction erases existing markers
|
* fix(nft): check the right pointer in trackingInitMain After threadGetArg() the guard re-tested threadHandle, so a NULL trackingInitHandle was dereferenced on the worker thread instead of logged. Reported by Qodo on #79. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(nft): cap the decompressed size of .zft archives inflateAll() doubled its buffer with no upper bound, so a small archive with a huge expansion ratio could exhaust memory. Archives expanding past MARKER_DECOMPRESS_MAX_SIZE (128 MB, overridable at build time) are now rejected with -1. Also documents that decompressMarkers() should write to new paths: an existing marker set there is not preserved on failure. Reported by Qodo on #79. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(nft): fail clearly when AR2_CAPABLE_ADAPTIVE_TEMPLATE is enabled The Mod tracking path never supported adaptive templates: with the option on, trackingMod2d.c did not compile (mismatched signature, redeclared templ2). trackingMod.h now stops the build with an explicit #error, and trackingMod2d.c includes it so it uses the public declaration of ar2Tracking2dSubMod(). Reported by Qodo on #79. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(nft): enforce small decompression limits and accept streams ending at the limit - the initial inflate buffer is now capped at MARKER_DECOMPRESS_MAX_SIZE, so limits below 4 MB are enforced - at the limit, zlib gets one spare output byte to finish the stream (final block, trailer); only output written there means the archive is too large - MARKER_DECOMPRESS_MAX_SIZE below 1 is a build error - new webarkit_nft_limit_test builds markerDecompress with a 1 MB limit: exactly at the limit, one byte over, and a limit below the initial buffer; run in CI Reported by Qodo on #80. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Release 0.10.0. Please merge with a merge commit (not squash), as for #73.
trackingInitMainchecks the right pointer.zftdecompression capped atMARKER_DECOMPRESS_MAX_SIZE(128 MB), including limits below 4 MB and archives exactly at the limit#errorifAR2_CAPABLE_ADAPTIVE_TEMPLATEis enabledwebarkit_nft_limit_test, run in CIThe Qodo findings on this PR are answered in their threads: 2, 3 and 5 are fixed by #80; 1 (existing marker set overwritten on failure) and 4 (NUL bytes in
.zftdata) are not changed, with the reasons given there.Tested with jsartoolkitNFT (webarkit/jsartoolkitNFT#687): full rebuild, vitest and node tests, and all examples, including the threaded ones.
After merging, tag
0.10.0onmasterand publish the release notes.🤖 Generated with Claude Code