Skip to content

fix(spf): preserve effect order across composition teardown - #65

Open
a-bro wants to merge 1 commit into
mmcc:mmcc/moqfrom
a-bro:codex/spf-effect-lifecycle-mmcc
Open

a-bro wants to merge 1 commit into
mmcc:mmcc/moqfrom
a-bro:codex/spf-effect-lifecycle-mmcc

Conversation

@a-bro

@a-bro a-bro commented Oct 16, 2026 •

Copy link
Copy Markdown

Replacing a MoQ player in the same page can leave its renderer idle while its subscriber receives decodable frames. Destroying the old composition calls Watcher.unwatch(), which swaps the last watched effect into the removed slot and can run the replacement renderer binding before setup. The binding returns without tracking the subscriber and never wires the renderer.

Keep live effects in registration order independently of watcher storage order. Disposing an effect also removes it from the flush iteration, so an earlier effect cannot cause a disposed body to run again.

Targets mmcc/moq at 8bf5170e1 directly. One commit, two files: the shared SPF scheduler and two regression tests. No publisher commits or publisher dependency are included. Supersedes a-bro#1.

Validation on this base:

  • Both new regressions fail on the unchanged mmcc/moq scheduler (2 failed, 3 passed).
  • The patched full SPF suite passes: 2,403 passed, 11 existing skips, no type errors.
  • SPF dependency build (pnpm exec vp run '@videojs/spf#build') passes; focused vp check has zero errors and three existing warnings.

The same scheduler change previously passed a separate 11/11 live workflow gate on the broader publisher integration tree, including normal H.264 browser publication, actual MoQ20 playback, same-page replacement and rebind after gateway renewal. That supplemental integration evidence is recorded in https://github.com/muxinc/relay-dev/pull/255; it is distinct from the current-base test run above.

@a-bro
a-bro force-pushed the codex/spf-effect-lifecycle-mmcc branch from 2e9a62c to e4f07a9 Compare October 16, 2026 18:18
@a-bro
a-bro changed the base branch from mmcc/moq-publisher to mmcc/moq October 16, 2026 18:18
@mmcc
mmcc marked this pull request as ready for review October 19, 2026 17:47
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T17:52:35.430199Z e4f07a9 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 2 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/spf/src/core/signals/effect.ts">

<violation number="1" location="packages/spf/src/core/signals/effect.ts:17">
P3: This makes every flush scan every live effect, even when only one effect is pending. Keep registration order while iterating only the pending effects, for example by assigning each effect a registration index and sorting the pending list by that index before running it.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic


for (const c of pending) {
pending.delete(c);
for (const c of effects) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: This makes every flush scan every live effect, even when only one effect is pending. Keep registration order while iterating only the pending effects, for example by assigning each effect a registration index and sorting the pending list by that index before running it.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/spf/src/core/signals/effect.ts, line 17:

<comment>This makes every flush scan every live effect, even when only one effect is pending. Keep registration order while iterating only the pending effects, for example by assigning each effect a registration index and sorting the pending list by that index before running it.</comment>

<file context>
@@ -1,21 +1,22 @@
 
-  for (const c of pending) {
-    pending.delete(c);
+  for (const c of effects) {
+    if (!pending.has(c)) continue;
+
</file context>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e4f07a95b7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


for (const c of pending) {
pending.delete(c);
for (const c of effects) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Update ordering documentation with the scheduler

For future scheduler and reactor maintenance, this loop now derives registration order from the live effects set rather than from Watcher.getPending(), but internal/design/spf/actor-reactor-factories.md:418-431, internal/design/spf/decisions.md:33-35, and internal/design/spf/signals.md:453-465 still say this load-bearing guarantee depends on watcher insertion order, while internal/design/spf/text-track-architecture.md:473-484 still treats explicit ordering as an open option. Those explanations are now factually wrong about the mechanism this fix relies on, so update them as part of this scheduler change.

AGENTS.md reference: AGENTS.md:L16-L16

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
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.

1 participant