Emscripten: WebGL: INVALID_ENUM: readPixels: invalid format

When using vtkOpenGLHardwareSelector one gets two errors

WebGL: INVALID_ENUM: readPixels: invalid format
GL_INVALID_OPERATION: Invalid format and type combination.

The errors arise from the javascript call

GLctx.readPixels(x, y, width, height, format, type, heap, pixels >> heapAccessShiftForWebGLHeap(heap))

in the generated code. This is triggered with the call to

vtkOpenGLHardwareSelector * h_sel = //...
// ...

Hence the same error occurs with PickProp on a renderer

vtkRenderer *r = // ...
// ...
r->PickProp(x, y);

The same behavior is observed with vtkOpenGLRenderer.

Please note that everything was compiled in compliance with instructions on the Examples page, and that other features work correctly.

Might anyone offer some insight into what might be happening? The CaptureBuffers method of vtkHardwareSelector invokes render_window->Render() under the hood, but this method seems to work properly outside of the above.

I also encountered the same problem, Mr. Ziga Sajovic, do you have an answer at last?