Repository navigation
fix(js): hang catalog/CMAF, watch rotation, and room metadata bugs - #9344
Conversation
Quest-Claim: 55fbbeb499cc0e90
…batim Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cross unrelated updates Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… its own output Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 6 seconds. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
✅ No new issues found.
Approach: sound. Each fix sits at the root cause: encode-time unwrapping (with the producer splitting parsed and written state so it never re-encodes its own output), a structural esds walk instead of a flag-blind scanner, rotation applied where dimensions are compared, and per-track computeds that dedupe on the track name.
Reviewed changes
I read the full diff at 975ac8b and traced each change against its callers and the helpers it uses.
@moq/hangcatalogencode(): writes unknowncontainer/projectionback asraw.Catalog.encodehas one in-repo caller,js/publish/src/catalog.ts, which now keeps the parsed draft in#valueand the encoded copy in#wire, so the non-idempotence the doc comment warns about can't come up there.@moq/publishCatalogProducer: comparisons for estimate monotonicity and change detection, and everyupdate, now read#wire. Eachmutateclones the parsed draft, so the producer never encodes its own output.@moq/hangstats/echo rendition maps:renditionsSchemamirrors the catalogrenditions()helper without the version skip. It is still__proto__-safe and still refuses the map on a malformed entry, as before.@moq/hangCMAF esds: walksES_Descriptor→DecoderConfigDescriptor→DecoderSpecificInfowithin the declared sizes. The optional fields are read in the §7.2.6.5 order (dependsOn, URL, OCR).decodeInitSegmentreads a singletrak, so a throw only refuses that one rendition.@moq/watchbyDimensions: turns the coded size withrotateDimensions(@moq/videois already a dependency).orientedRenditionsalready accounted for rotation throughCatalog.Video.orientation, so the two filters now agree.@moq/roommetadata:HangSchemavalidates only theuser/previewentries. The user and preview subscriptions are now separate effects keyed onComputedtrack names.Signal.setskips notifying when the value is unchanged, so an unrelated catalog update leaves both subscriptions alone.
I couldn't run the tests here: bun install fails because the @moq/libav build needs Nix.
claude-opus-5-5 | 𝕏

Fixes five JS media correctness bugs from the pre-cut full-codebase audit, and finishes
quest/m1/precut-audit/js-media-fixes.md.Changes
@moq/hangcatalog encode (js/hang/src/catalog/root.ts):encode()used to write an unknowncontainerorprojectionas the parser's{ kind: "unknown", raw }wrapper. It now writes the original object, so a republisher passes a future kind through unchanged, asrs/hang's serializers do.@moq/publishcatalog producer (js/publish/src/catalog.ts): it used to storeencode()'s output and re-encode it on the next edit. Now thatencode()writes unknown kinds verbatim, it is no longer idempotent: a container whose real kind is the string"unknown"would be dropped on the next edit. The producer now keeps the parsed catalog it edits apart from the written one, and encodes only the parsed one. Found in local review.@moq/hangstats and echo (js/hang/src/snapshot.ts,stats.ts,echo.ts): report rendition maps used the catalog'srenditions()helper. That helper skipped any entry withversionabove the catalog draft and refused the report on a non-numericversion. They now userenditionsSchema, a plain__proto__-safe map. Like Rust'sBTreeMap<String, Rendition>, it treatsversionas just another unknown field.@moq/hangCMAF esds (js/hang/src/cmaf/decode.ts): the old flat scanner assumed the ES_Descriptor flags were zero. WithstreamDependenceFlagorURL_Flagset, it misread the descriptors and returned no AudioSpecificConfig, so AAC got no decoder description. The new parser walks ES_Descriptor → DecoderConfigDescriptor → DecoderSpecificInfo inside each descriptor's declared size, skips the optional fields (ISO/IEC 14496-1 §7.2.6.5), and throws on a truncated descriptor where the old scanner silently returned nothing.@moq/watchrendition pick (js/watch/src/video/source.ts):byDimensionscompared coded sizes against the element's displayed box. It now turns the coded size by the section'srotationfirst, using@moq/video'srotateDimensions. A 90°/270° stream in a portrait box now picks the largest rendition that fits as shown.Target.width/heightdocs now say they are sizes as shown.@moq/roommetadata (js/room/src/metadata.ts):catalog.hangis validated with zod, checking only theuser/previewentries it reads so app extensions still pass through. A malformed section is refused as absent, with a warning. Each track name is its own computed, so a catalog update that leaves it alone (a new rendition,hang.chat) keeps the subscription. Before, every such update cleared the signals and resubscribed.Choices made without asking:
undefined, per fail-loud. A valid esds with no DecoderSpecificInfo (such as MP3) still returnsundefined.hangsection warns and is treated as absent, matching howsubscribeJsonalready treats malformed track values.Validation
HEADbefore the fix. One exception: the OCR-only and every-flag esds cases happened to pass under the old scanner by luck.decodeInitSegment's description to the extradataffprobereads. All five match (120856e500). The old parser returned nothing for 0x80 and 0x40.just checkpasses.<moq-watch>with a rotated broadcast. The watch test drives the realSourcewith real signals.Public API
None breaking.
@moq/publishCatalogProducerkeeps its edit state in the parsed shape (internal).@moq/watchTarget.width/heightdocs now say they are sizes as shown; that is a behavior fix for rotated streams.@moq/hangencode()now writes unknown containers and projections verbatim. Wire: none.Caused by
{ kind: "unknown", raw }container wrapper without unwrapping it inencode(found by reviewer; pre-cut audit)renditions()map, with its version skipping, for stats and echo reports (found by reviewer; pre-cut audit)byDimensionscomparing coded sizes, ignoring rotation (found by reviewer; pre-cut audit)hangsection (found by reviewer; pre-cut audit)Follow-ups
@moq/room'ssubscribeJsonmatcheserr instanceof z.core.$ZodError, which breaks the rule against matching on errors. The proposed fix is for@moq/json'sSnapshot.Consumerto skip and report schema refusals itself. No open decisions; the recommended shape is in its Plan.Models
Size: M
Implementer: Claude Code, claude-opus-5-5, unknown effort (arm A)
🤖 Generated with Claude Code
(Written by Claude Opus 5.5)
Review
Rewritten by
quest reviewafter each round.Head: 975ac8b
Base: origin/main at 675206c
Risk: high,
Changes to hang catalog JSON serialization and public video target semantics can affect published consumers and deployed peers; reverting restores the code but cannot recall catalogs already transmitted.Classified: high by Codex, gpt-6.1-sol, low effort, session
01a201a0-cedc-7dd1-b8bb-9737564ad701Reviewer: Codex, gpt-6.1-sol, high effort
Session:
01a20195-b459-7a13-81cf-2d7cdfec3c55, round 2Score: 10/10,
The parsed-state separation fixes the earlier finding, and inspection of the incremental changes found no new issues.Rounds: 2; first round 1 (medium 1); findings 1 (medium 1): fixed 1, refuted 0, open 0
Findings: none
The last round's findings, at 9bc8b00:
js/hang/src/catalog/root.ts:147:Keep serialized unknown kinds out of editable catalog state;js/publish/src/catalog.ts now retains parsed edits in #value and publishes #wire, preserving unknown container and projection wrappers across later edits; the added regression test covers this scenario.