(rsg) Fix stack overflow from ContentNode parentField notification cascade#905
(rsg) Fix stack overflow from ContentNode parentField notification cascade#905jeremy-albinet wants to merge 2 commits intolvcabral:masterfrom
Conversation
|
A note on the approach: I want to be upfront that the The cleanest change here is the The deeper question is: why doesn't real Roku firmware recurse here? It likely either queues field notifications asynchronously or has built-in reentrancy protection at the observer dispatch level. Matching that behavior would be the proper fix. I'm happy to rework this if you have a preferred approach — you know the engine internals far better than I do. Feel free to cherry-pick just the parts that make sense. |
|
@jeremy-albinet thanks for the PR, I had this recursiveness issue on my backlog to take a look. A similar approach exists in Please use I will review and test your code and update my review. |
|
@jeremy-albinet do you have simple way to reproduce this issue ? Can you add it on the CLI tests? |
Replace global recursion guards with field-level queued/coalesced notification dispatch. Remove Node setValue depth cap and ContentNode static parent guard, and add a regression test that reproduces cross-node parentField observer loops.
f07dc4b to
a1b4c8a
Compare
|
Updated this PR with a cleaner fix and amended commit ( What changed:
|
…ecursion fix Add two CLI test apps exercising distinct recursion vectors: - contentnode-recursion-app: cross-field observer recursion via 1200 duplicate parentField-propagated observers (stack overflow without fix) - contentnode-parentfield-app: parentField notification cycle with observer stacking inside callbacks (escalating callback counts) Replace old monkeypatched unit test with proper end-to-end CLI tests. Add JSDoc on Field.flushNotificationQueue and CHANGELOG entry.
|
|
Pushed the CLI repro tests you asked for. Two test apps (same pattern as Also cleaned up: removed the old unit test, added CHANGELOG entry and JSDoc on the dispatch method. Happy to adjust anything — JSDoc verbosity, changelog wording, test structure — feel free to push changes directly to my branch too. |



Summary
Fixes recursive SceneGraph observer cascades that can cause stack overflows in
ContentNodeupdate loops (issue #904), using a field-level notification dispatcher instead of global recursion guards.Root Cause
ContentNodeparent-field observers can triggersetValue()on other nodes, which can synchronously notify back and form a recursive loop.Changes
Field.notifyObservers()now uses a queued, iterative dispatcher.Node.setValue().test/brsTypes/ContentNodeRecursion.test.jsWhy this approach
Validation
npm test -- test/brsTypes/ContentNodeRecursion.test.js --runInBandnpm test -- test/brsTypes/Serializer.test.js --runInBandnpm test -- test/cli/cli.test.js --runInBand -t "SceneGraph Observers Test"