Skip to content

fix(SUP-52427): prevent infinite setState loop in Watermark component [HF v0.83.6] - #1171

Open
MosheMaorKaltura wants to merge 5 commits into
masterfrom
fix/SUP-52427-watermark-loop-v0.83.6
Open

fix(SUP-52427): prevent infinite setState loop in Watermark component [HF v0.83.6]#1171
MosheMaorKaltura wants to merge 5 commits into
masterfrom
fix/SUP-52427-watermark-loop-v0.83.6

Conversation

@MosheMaorKaltura

Copy link
Copy Markdown
Collaborator

Hotfix for v0.83.6

Backport of #1170 targeting the v0.83.6 release tag.

Problem

componentDidUpdate called _loadImageDimension() unconditionally on every render. Inside _loadImageDimension, img.onload calls setState({imgWidth, imgHeight}), which triggers another componentDidUpdate — creating an infinite loop of re-renders and repeated HTTP requests for the watermark image.

The loop was introduced in feat(FEC-14949) #1160 which moved _loadImageDimension from componentWillMount into componentDidUpdate without adding a guard.

Observed: Watermark image URL requested 2000+ times per session. Reproduces after a few seek operations on the player.

Fix

  1. Restore the initial load call in componentDidMount (after _handleWatermarkUrl), so static config.img URLs load dimensions on mount.
  2. Guard componentDidUpdate to only call _loadImageDimension when the image URL actually changes — prevents the setState feedback loop.

Test page

Verified with local reproduction pages:

  • Repro: counter climbs to 2000+ showing the loop
  • Fix: counter stays at 1, loop blocked after first load

🤖 Generated with Claude Code

…eDimension

componentDidUpdate called _loadImageDimension unconditionally, which called
setState inside img.onload, triggering another componentDidUpdate — causing
an infinite loop of re-renders and repeated HTTP requests for the watermark image.

Fix: call _loadImageDimension once in componentDidMount for the initial load,
and in componentDidUpdate only when the image URL actually changes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants