Skip to content

RTTR: ReferenceError: WebGLRenderingContext is not defined #2875

@Panda64

Description

@Panda64

Hi, I recently tried upgrading three.js from 152 to 153 and am running into some issues with RTTR. For every test that uses RTTR (const renderer = await ReactThreeTestRenderer.create()), I get the errors:

ReferenceError: WebGLRenderingContext is not defined
console.error
    THREE.WebGLRenderer: WebGLRenderingContext is not defined

This seems to be in relation to mrdoob/three.js#25959 . When I manually went into the build code and commented out https://github.com/mrdoob/three.js/pull/25959/files , my tests pass again. It is confusing to me because while trying to debug, I replaced the console.error message with _gl and saw:

console.error
    WebGLRenderingContext {
      getShaderPrecisionFormat: [Function (anonymous)],
      GL_VERSION: 7938,
      SCISSOR_BOX: 3088,
      VIEWPORT: 2978,
      getParameter: [Function (anonymous)],
      getExtension: [Function (anonymous)],
      getProgramInfoLog: [Function (anonymous)],
      getShaderInfoLog: [Function (anonymous)],
      canvas: HTMLCanvasElement {
        addEventListener: [Function (anonymous)],
        removeEventListener: [Function (anonymous)],
        getContext: [Function: getContext]
      },
     ...

My actual app works fine otherwise (no related console messages etc.), it seems to just be the RTTR tests.

I am using CRA via npm to build/run/test everything. I tried recreating this error in a codesandbox, but no luck. This makes me want to believe that it's something wrong with my build setup or local environment, but I don't know where I'd begin to look.

Package Versions:
three: 0.153.0
@react-three/test-renderer: 8.1.2
@react-three/fiber: 8.13.0
@react-three/drei: 9.73.4
react: 18.2.0
react-dom: 18.2.0
react-scripts: 5.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions