Skip to content

Fix unloaded HTMLImageElement uniforms - #277

Merged
itsdouges merged 1 commit into
paper-design:mainfrom
teeverc:fix/image-uniform-loading
Jul 24, 2026
Merged

Fix unloaded HTMLImageElement uniforms#277
itsdouges merged 1 commit into
paper-design:mainfrom
teeverc:fix/image-uniform-loading

Conversation

@teeverc

@teeverc teeverc commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Wait for HTMLImageElement uniforms to finish decoding before passing them to the vanilla ShaderMount.

Fixes race condition: Uncaught (in promise) Error: Paper Shaders: image for uniform u_noiseTexture must be fully loaded for cache miss.

Problem

Some shaders create image uniforms internally, such as the embedded u_noiseTexture. processUniforms currently passes these images through immediately, even if they have not finished loading.

On a cold page load, WebGL can therefore receive an image with a zero naturalWidth and throw:

Paper Shaders: image for uniform u_noiseTexture must be fully loaded

Change

Use HTMLImageElement.decode() and add its promise to the existing imageLoadPromises collection. This uses the same waiting mechanism already used for string image uniforms.

This is a follow-up to #244 and #253.

Verification

  • bun run build
  • bun run --filter @paper-design/shaders-react type-check
  • Verified against a GrainGradient cold-load failure in a React application

@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

@teeverc is attempting to deploy a commit to the Paper Design Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Jul 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
shaders-docs Ready Ready Preview, Comment Jul 12, 2026 4:30am

Request Review

@itsdouges

Copy link
Copy Markdown
Contributor

thanks, looks good.

@itsdouges
itsdouges merged commit d9540ab into paper-design:main Jul 24, 2026
3 checks passed
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.

2 participants