Change WebGLRenderer Context Attribute After Creation

I’m trying to have a toggle that would switch between setting powerPreference to “default” and “high-performance” within the WebGLRenderer context. Is it possible to update the context attributes of WebGLRenderer if the renderer has already been created?

No, sorry. You have to dispose the entire renderer and create a new one (which will also create a new rendering context).

It might be worth noting that if you dispose of an existing renderer and create a new one that renders the same scene without explicitly disposing of all geometry, materials, and textures you could run into the memory leak issue related to #20346. Ie if the user switches back and forth between high and low quality renderers the dispose listeners will expand indefinitely and potentially retain WebGL context references until dispose is called on the objects.

Until something like WeakRef can be used to dispose of all objects when disposing of the renderer it’s best to make sure you call dispose on everything you have kept a handle to.