Fix/load decoded bitmask - #252
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds raw bitmask imports, delayed loaders, and faster subtask annotation replacement.
Changes:
- Supports validated raw
Uint8Arraybitmasks 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.
Contributor
There was a problem hiding this comment.
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_payloadis declared as a type guard forULabelRawMaskPayload(which specifiesdata: Uint8Array), but it currently returns true forUint8ClampedArrayas well. That makes the type predicate unsound and can lead to callers treating a clamped array as aUint8Array(and also conflicts with the documented{ data: Uint8Array, ... }payload shape). Either widen the payload type + adjustfrom_rawaccordingly, or restrict the guard toUint8Arrayonly.
if (!(p.data instanceof Uint8Array) && !(p.data instanceof Uint8ClampedArray)) return false;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Load Decoded Bitmasks
Description
Uint8Arraypayloads. In addition to the existing RLE{ counts, size }shape,spatial_payloadmay 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.ULabelLoader.add_loader_div()now appends the overlay hidden and reveals it only after a delay (200 ms by default). Callers can pass an explicitdelay_ms— including0to opt back into immediate-show.set_annotations(). The old per-annotationdestroy_annotation_contextloop 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 resetsannotation_contexts. Eliminates wasted redraws.reset_interaction_state()inset_annotations()is now scoped to the target subtask. Previously the reset ran on every subtask, wipingis_in_edit/active_idon subtasks the caller wasn't touching.PR Checklist
package.jsonhas been bumped since last releasepackage.jsonandsrc/version.jsapi_spec.md)changelog.mdBreaking API Changes
No