I have a PNG file with dimensions 128x32128 (equivalent to 251 128x128 layers) and when I try the following:
gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 1, gl.SRGB8_ALPHA8, 128, 128, 251)
gl.texSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, 128, 128, 251, gl.RGBA, gl.UNSIGNED_BYTE, imageElement)
// imageElement.src = 128x32128.png
I get a browser error reading WebGL: INVALID_VALUE: texSubImage3D: width, height or depth out of range
However, if I try something very similar with another image of dimension 128x8192 (equivalent to 64 layers of 128x128) I get no error:
gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 1, gl.SRGB8_ALPHA8, 128, 128, 32)
gl.texSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, 128, 128, 32, gl.RGBA, gl.UNSIGNED_BYTE, imageElement)
// imageElement.src = 128x8192.png
However, if I try the same code with the original image I get the same error:
gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 1, gl.SRGB8_ALPHA8, 128, 128, 32)
gl.texSubImage3D(gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, 128, 128, 32, gl.RGBA, gl.UNSIGNED_BYTE, imageElement)
// imageElement.src = 128x32128.png
This does not make any sense. Surely this is an implementation bug, as the only thing that changed from example 2 to example 3 was the image, not the parameters to texSubImage3D.
Browser: Chrome v67 on Windows 7 x64
This appears to be a bug in Chrome as it works in Firefox
Filed a bug