Skip to content

Code audit: find duplicated / orphan / unused code in WebARKit (excluding vendored lib/SRC and AR/ headers) #50

Description

@kalwalt

Goal

Sweep the WebARKit-specific C++ code for duplicated, orphan, or unused code, and clean it up. Several recent fixes (#43, #44, #46) surfaced vestigial paths (e.g. the disabled pyrDown block, the no-op _featureDetectScaleFactor rescale) that had been carrying dead weight for a long time. Likely there is more.

Scope

In scope — WebARKit/ only:

  • WebARKit/WebARKitTrackers/WebARKitOpticalTracking/WebARKitTracker.cpp + headers
  • WebARKit/WebARKitTrackers/WebARKitOpticalTracking/TrackingPointSelector.{h,cpp}
  • WebARKit/WebARKitTrackers/WebARKitOpticalTracking/HomographyInfo.{h,cpp}
  • WebARKit/WebARKitTrackers/WebARKitOpticalTracking/WebARKitConfig.{h,cpp}
  • WebARKit/WebARKitManager.{h,cpp}, WebARKit/WebARKitCamera.{h,cpp}, WebARKit/WebARKitGL.{h,cpp}, WebARKit/WebARKitPattern.{h,cpp}, WebARKit/WebARKitLog.{h,cpp}

Out of scope — vendored code:

  • lib/SRC/AR/**, lib/SRC/ARUtil/**, include/AR/** (vendored old ARToolKit5 sources/headers — untouched).
  • OpenCV and submodules under opencv/, opencv_contrib/.

Note: ArtoolkitX remains the design reference for the OCVT planar tracker under WebARKit/WebARKitTrackers/WebARKitOpticalTracking/ (cross-checked against artoolkitx/artoolkitx); that is separate from the vendored ARToolKit5 utility code.

Companion scope — also audit webarkit/webarkit-testing

  • src/ (JS controller + utils)
  • emscripten/ glue (WebARKitJS.{h,cpp}, bindings.cpp)
  • examples/ (post-Fix CV->GL pose conversion in updateTrackable() #36 cleanup) — small surface; spot-check for orphans
  • tools/makem.js (any orphan source entries)
  • Look for dead package.json scripts / webpack.config.js targets (already trimmed SpeedyVisionSinkImageData in webarkit-testing#41).

What to look for

  • Dead members: fields declared on WebARKitTrackerImpl and friends that are written but never read (or never written).
  • Commented-out blocks that have outlived their purpose (e.g. the pyrDown/detection-guard blocks were finally removed in Feature keypoints double-scaled for frames larger than featureImageMinSize (marker mis-localized at ~2x position) #43/Restore downsampled feature detection + single-marker detection guard for performance (reconcile with ArtoolkitX OCVT) #44 prep; check for others).
  • _trackVizActive / TrackerVisualization — referenced throughout but no public toggle / not consumed by any example. Confirm dead-or-load-bearing.
  • getPoseMatrix vs getPoseMatrix2 — both are bound to JS but only getPoseMatrix2() is read in process_raw(). Is the other unused?
  • computePose in WebARKitPattern.cpp — declared but not called from anywhere in the live path.
  • getTransformationMatrix vs getGLViewMatrix vs matrixGL_RH — three GL-ish matrices flowing through the manager + bindings; some may be unused by every consumer.
  • points2d / points3d on _pattern — populated in initTracker but check for use.
  • Duplicated helpers (e.g. convert2Grayscale, GrayScale JS class, and convertJSArrayToNumberVector paths).
  • process_raw vs processFrame — both shapes exist; one wraps the other; check if both are still consumed.
  • Header-only declarations whose .cpp definitions are gone, and vice-versa.

Acceptance

  • Per-file inventory of dead / duplicated / orphan code, with proposed removal.
  • Each removal verified to leave behavior unchanged (recompile + the static-image and webcam examples track).
  • If any "dead-looking" symbol turns out to be load-bearing (used by another consumer / tooling), document why and leave it.
  • Repeat the inventory + cleanup pass on the in-scope parts of webarkit-testing.

Tooling

  • clang-tidy (misc-unused-using-decls, bugprone-*, readability-*)
  • compiler warnings with -Wunused-* + -Wmissing-declarations
  • cppcheck for dead-code detection
  • ripgrep / xref for "declared but never called" sweeps

Notes

This is a quality / debt issue, not a bug — defer behind active bug work (#44 perf, #48 markerless).

Metadata

Metadata

Assignees

Labels

C/C++ codeconcerning the C/C++ code design and improvementsEmscriptenenhancementNew feature or request

Fields

No fields configured for Feature.

Projects

Status
Done

Relationships

None yet

Development

No branches or pull requests

Issue actions