Skip to content

Performance & modernization directions (from shader benchmark) #540

Open

Description

@gre

Findings from benchmark-shader-solutions (same animated shader built with raw WebGL, gl-react, Skia, WebGPU, native…).

Web: gl-react is close to raw WebGL but pays everywhere: +5.7 pts CPU, 2× JS heap, slower first frame, +38 kB gzip vs +4 kB, and a global shim needed in Vite.
React Native: tied to Expo / expo-gl (OpenGL ES), blocks the JS thread every frame, no pixel-ratio control, MSAA always on, heaviest setup of all solutions.

Directions (big picture)

  1. Animate without React re-renders. Uniforms that are read at draw time (functions, refs, or shared values on RN), plus a single Surface loop. React describes the graph; it doesn't drive every frame.
  2. Compile the graph once, execute cheaply per frame. A flat draw plan built at commit time, executed per frame without allocations. Replace gl-shader with a thin internal layer.
  3. Slim, modern package. Drop legacy deps (gl-shader, ndarray, typedarray-pool, raf, prop-types…), ship ESM, globalThis, no bundler config needed.
  4. Rethink the React Native backend. Short term: expose pixel ratio and MSAA in gl-react-expo. Longer term: move off Expo/OpenGL ES, e.g. run the draw plan on the UI thread / another GPU backend.
  5. Surface ergonomics. Auto-sizing, pixelRatio everywhere, context-loss handling.

Next step: a benchmark page in the repo to profile where the overhead actually comes from, then prototype 1 and 2.

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions