Skip to content

Fix/load decoded bitmask - #252

Merged
TrevorBurgoyne merged 5 commits into
mainfrom
fix/load-decoded-bitmask
Aug 13, 2026
Merged

Fix/load decoded bitmask#252
TrevorBurgoyne merged 5 commits into
mainfrom
fix/load-decoded-bitmask

Conversation

@TrevorBurgoyne

Copy link
Copy Markdown
Member

Load Decoded Bitmasks

Description

  • Bitmask annotations can now be imported as raw Uint8Array payloads. In addition to the existing RLE { counts, size } shape, spatial_payload may now be { data: Uint8Array, size: [height, width] }. This lets callers that already have the mask as a pixel buffer skip the RLE encode step before handing it to ULabel.
  • Loader no longer flashes on fast operations. ULabelLoader.add_loader_div() now appends the overlay hidden and reveals it only after a delay (200 ms by default). Callers can pass an explicit delay_ms — including 0 to opt back into immediate-show.
  • Performance: bulk teardown in set_annotations(). The old per-annotation destroy_annotation_context loop redrew remaining siblings on each canvas after every removal. The new path drops caches on outgoing annotations, empties the subtask's canvasses container in one shot, and resets annotation_contexts. Eliminates wasted redraws.
  • Correctness: reset_interaction_state() in set_annotations() is now scoped to the target subtask. Previously the reset ran on every subtask, wiping is_in_edit / active_id on subtasks the caller wasn't touching.

PR Checklist

  • Merged latest main
  • Version number in package.json has been bumped since last release
  • Version numbers match between package package.json and src/version.js
  • Updated documentation if necessary (currently just in api_spec.md)
  • Added changes to changelog.md

Breaking API Changes

No

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds raw bitmask imports, delayed loaders, and faster subtask annotation replacement.

Changes:

  • Supports validated raw Uint8Array bitmasks with RLE export.
  • Delays loader visibility to avoid flashing.
  • Adds bulk canvas teardown and subtask-scoped resets.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/mask_utils.ts Adds raw mask support.
src/annotation.ts Validates raw bitmasks.
src/index.js Imports/exports masks and optimizes teardown.
src/loader.ts Adds delayed loader display.
src/version.js Bumps version.
tests/mask_utils.test.js Tests raw masks.
tests/loader.test.js Tests loader delay.
tests/annotation.test.js Tests imports and teardown.
api_spec.md Documents raw payloads.
CHANGELOG.md Records release changes.
package.json Bumps package version.
package-lock.json Synchronizes lockfile version.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/mask_utils.ts
Comment thread CHANGELOG.md Outdated
Comment thread src/index.js
Comment thread src/loader.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/mask_utils.ts:30

  • is_raw_mask_payload is declared as a type guard for ULabelRawMaskPayload (which specifies data: Uint8Array), but it currently returns true for Uint8ClampedArray as well. That makes the type predicate unsound and can lead to callers treating a clamped array as a Uint8Array (and also conflicts with the documented { data: Uint8Array, ... } payload shape). Either widen the payload type + adjust from_raw accordingly, or restrict the guard to Uint8Array only.
    if (!(p.data instanceof Uint8Array) && !(p.data instanceof Uint8ClampedArray)) return false;

@TrevorBurgoyne
TrevorBurgoyne merged commit 610495d into main Aug 13, 2026
5 checks passed
@TrevorBurgoyne
TrevorBurgoyne deleted the fix/load-decoded-bitmask branch August 13, 2026 16:19
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.

2 participants