View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0032084 | Open CASCADE | OCCT:Visualization | public | 2021-01-25 00:52 | 2023-01-17 02:37 |
Reporter | kgv | Assigned To | bugmaster | ||
Priority | normal | Severity | minor | ||
Status | closed | Resolution | no change required | ||
Platform | Mac | OS | OS | ||
Product Version | 7.5.0 | ||||
Target Version | 7.8.0 | ||||
Summary | 0032084: Visualization - WebGL sample errors when run in Safari browser with experimental WebGL 2.0 option | ||||
Description | Safari developers are trying to implement WebGL 2.0 support to their browser, but so far it remains partially broken and can be enabled only as experimental feature: https://trac.webkit.org/wiki/AngleforWebGL Enabling this flag within OCCT WebGL samples on modern Safari 14 on both macOS and iOS devices shows that it's implementation is indeed still incomplete. So far within OCCT viewer the issue with glUniform* methods have been observed (glUniform2fv, glUniform4fv, glUniformMatrix4fv actually triggered) - Safari generates weird GL_INVALID_OPERATION error message. Investigation shown that issue happens specifically with "garbage-free entry points" introduced by WebGL 2.0 used by Emscripten SDK implicitly for optimization purposes. Disabling this feature allows OCCT viewer to be initialized: function _glUniform4fv(location, count, value) { GL.validateGLObjectID(GL.uniforms, location, 'glUniform4fv', 'location'); assert((value & 3) == 0, 'Pointer to float data passed to glUniform4fv must be aligned to four bytes!'); if (GL.currentContext.version >= 2) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible. - GLctx.uniform4fv(GL.uniforms[location], HEAPF32, value>>2, count*4); - return; + //GLctx.uniform4fv(GL.uniforms[location], HEAPF32, value>>2, count*4); + //return; } if (count <= 72) { // avoid allocation when uploading few enough uniforms var view = miniTempWebGLFloatBuffers[4*count-1]; // hoist the heap out of the loop for size and for pthreads+growth. var heap = HEAPF32; value >>= 2; for (var i = 0; i < 4 * count; i += 4) { var dst = value + i; view[i] = heap[dst]; view[i + 1] = heap[dst + 1]; view[i + 2] = heap[dst + 2]; view[i + 3] = heap[dst + 3]; } } else { var view = HEAPF32.subarray((value)>>2,(value+count*16)>>2); } GLctx.uniform4fv(GL.uniforms[location], view); } Unfortunately, this code is part of Emscripten SDK, so cannot be easily worked around on OCCT level. This issue is to track state of the bug - when it will be fixed in Safari, Emscripten or another proposals will be given for implementing a workaround. | ||||
Additional information and documentation updates | WebGL2EntryPoints are NOT implemented by experimental WebGL 2.0 context feature in Safari 14.x causing functions like `glUniform4fv()` to fail with `GL_INVALID_OPERATION`. The first Chrome versions implementing WebGL 2.0 have similar issue, so that Emscripten had even workaround for this in code based on Chrome version check, however this workaround has been removed since Emscripten 1.39.5, so that there is no place for it in up-to-date Emscripten versions: https://github.com/emscripten-core/emscripten/pull/9919 ----------------------------- src/library_webgl.js ----------------------------- index d3051022c..6e53d920c 100644 @@ -807,21 +807,25 @@ var LibraryGL = { #if USE_PTHREADS {{{ makeSetValue('handle', 4, '_pthread_self()', 'i32')}}}; // the thread pointer of the thread that owns the control of the context #endif + // workaround Safari bug returning WebGL 1.0 context by canvas.getContext("webgl2") if WebGL context was already created + var majVerWebGl = (typeof WebGL2RenderingContext === 'undefined' || !(ctx instanceof WebGL2RenderingContext)) ? 1 : webGLContextAttributes.majorVersion; var context = { handle: handle, attributes: webGLContextAttributes, - version: webGLContextAttributes.majorVersion, + version: majVerWebGl, GLctx: ctx }; #if USE_WEBGL2 // BUG: Workaround Chrome WebGL 2 issue: the first shipped versions of WebGL 2 in Chrome did not actually implement the new WebGL 2 functions. // Those are supported only in Chrome 58 and newer. + // The same is for the first experimental WebGL 2.0 implementations in Safari 14. function getChromeVersion() { var raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./); return raw ? parseInt(raw[2], 10) : false; } - context.supportsWebGL2EntryPoints = (context.version >= 2) && (getChromeVersion() === false || getChromeVersion() >= 58); + context.supportsWebGL2EntryPoints = (context.version >= 2) && (getChromeVersion() === false || getChromeVersion() >= 58) + && !navigator.userAgent.includes("AppleWebKit/"); #endif #if WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG | ||||
Tags | No tags attached. | ||||
Test case number | |||||
related to | 0032083 | closed | bugmaster | Open CASCADE | Visualization, TKOpenGl - PBR rendering is unavailable on Apple A12 Bionic (iPad) |
related to | 0032081 | closed | bugmaster | Open CASCADE | Visualization - WebGL sample errors when run in Safari browser with WebGL 1.0 |
related to | 0032082 | closed | kgv | Open CASCADE | Visualization, TKOpenGl - improve formatting of error messages |
Date Modified | Username | Field | Change |
---|---|---|---|
2021-01-25 00:52 | kgv | New Issue | |
2021-01-25 00:52 | kgv | Assigned To | => kgv |
2021-01-25 00:53 | kgv | Relationship added | related to 0032083 |
2021-01-25 00:53 | kgv | Relationship added | related to 0032081 |
2021-01-25 00:53 | kgv | Relationship added | related to 0032082 |
2021-02-15 09:37 | kgv | Additional Information Updated | |
2021-02-15 09:38 | kgv | Additional Information Updated | |
2021-09-09 22:28 | kgv | Target Version | 7.6.0 => 7.7.0 |
2022-02-10 00:53 | kgv | Note Added: 0106839 | |
2022-02-10 00:53 | kgv | Assigned To | kgv => bugmaster |
2022-02-10 00:53 | kgv | Status | new => feedback |
2022-10-24 10:43 |
|
Target Version | 7.7.0 => 7.8.0 |
2023-01-17 02:37 | vglukhik | Status | feedback => closed |
2023-01-17 02:37 | vglukhik | Resolution | open => no change required |
2023-01-17 02:37 | vglukhik | Note Added: 0112844 |