Skip to content

fix(Grainient): render initial frame in setSize to prevent flicker#929

Open
anonymousRecords wants to merge 1 commit intoDavidHDev:mainfrom
anonymousRecords:feat/fix-grainient-mount-flicker
Open

fix(Grainient): render initial frame in setSize to prevent flicker#929
anonymousRecords wants to merge 1 commit intoDavidHDev:mainfrom
anonymousRecords:feat/fix-grainient-mount-flicker

Conversation

@anonymousRecords
Copy link
Copy Markdown

Problem

The Grainient component flickers on mount. When the component mounts, setSize() is called to configure the canvas dimensions — but renderer.render() only runs inside the requestAnimationFrame loop. This means the canvas stays blank for ~1 frame between mount and the first rAF tick, causing a visible flash against the page background.

Root Cause

renderer.render() was only called inside the animation loop, so the canvas stays blank until the next rAF tick fires.

  const setSize = () => {                                                
    renderer.setSize(width, height);                                                                                                     
    res[0] = gl.drawingBufferWidth;            
    res[1] = gl.drawingBufferHeight;                                                                                                     
    // ❌ No render here — canvas is blank until next rAF                
};           

Fix

Added renderer.render({ scene: mesh }) inside setSize() so the canvas draws immediately whenever the size is set.

  const setSize = () => {                                                                                                                
    renderer.setSize(width, height);                                     
    res[0] = gl.drawingBufferWidth;                          
    res[1] = gl.drawingBufferHeight;           
    renderer.render({ scene: mesh }); // ✅ Render immediately
  };        

This fix is applied to all 4 variants of the Grainient component (JS/TS × CSS/Tailwind).

▎ Note: The same issue exists in Plasma and other OGL-based components — a follow-up PR will address those.

Preview

AS-IS

react-bits-as-is

TO-BE

화면 기록 2026-03-30 17 28 32

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