Skip to content

Fix edge case when doing el.texture.src = 'some-valid-src' - #619

Merged
jfboeve merged 3 commits into
rdkcentral:masterfrom
guilhermesimoes:bugfix/invalid-then-valid-tex
Oct 9, 2026
Merged

jfboeve merged 3 commits into
rdkcentral:masterfrom
guilhermesimoes:bugfix/invalid-then-valid-tex

Conversation

@guilhermesimoes

@guilhermesimoes guilhermesimoes commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Fix regression introduced in #616, that manifests in the following case:

  1. Element is already active (visible and within bounds)
  2. We set an invalid src, like el.src = '' or el.src = undefined
  3. Finally we do el.texture.src = 'some-valid-src'

If on step 3 we do el.src = 'some-valid-src' then everything works ok.
If between steps 2 and 3 the element goes inactive and then active, everything also works ok.

We're currently refactoring the Peacock app to always do el.src = '...' instead of el.texture.src = '...' precisely because these setters go through slightly different paths and their behaviours differ.

Copilot AI balanced review requested due to automatic review settings October 8, 2026 15:45
Comment thread src/tree/Element.mjs
Comment on lines -584 to -585
if (this.__enabled) {
this.__texture.addElement(this);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Basically this is the line that always needs to run when the element is enabled, whether the texture is valid or not.

@guilhermesimoes guilhermesimoes changed the title Bugfix/invalid then valid tex Fix edge case when doing `el.texture.src = 'some-valid-src' Oct 8, 2026
@guilhermesimoes guilhermesimoes changed the title Fix edge case when doing `el.texture.src = 'some-valid-src' Fix edge case when doing el.texture.src = 'some-valid-src' Oct 8, 2026

Copilot AI 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.

🟡 Changes recommended

The regression test explicitly forces loading instead of validating the documented automatic loading path.

1 open finding
What changed in this PR

Fixes texture recovery when an active element’s invalid texture is later given a valid source.

Changes:

  • Registers enabled elements with invalid textures.
  • Adds regression coverage for invalid-to-valid sources.
File Description
src/​tree/​Element.mjs Registers textures before validity checks.
tests/​textures/​test.textures.js Adds invalid-to-valid loading coverage.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Comment thread tests/textures/test.textures.js Outdated
Copilot AI balanced review requested due to automatic review settings October 8, 2026 15:52

Copilot AI 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.

🔵 Needs a closer look

The regression test does not make the element active before changing its source, so it misses the reported failure path.

0 open findings

1 resolved since last review
Previously missed (1)

In code that hasn't changed since last review

Medium severity Test does not reproduce active-element regression

tests/​textures/​test.textures.js:186

This does not currently reproduce the reported active-element regression: the first animation frame runs only after the synchronous item.src assignments, and a new element starts outside the bounds margin, so it transitions from inactive to active afterward—the path the PR description says already works. Draw one frame (and assert active) before assigning the invalid source so this test fails against the regressed implementation.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@jfboeve
jfboeve merged commit b82ba60 into rdkcentral:master Oct 9, 2026
10 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants