Skip to content

1.38.31 Failed 'querySelector' (WASM & WEBGL2 & DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR) + test_webgl_offscreen_canvas_in_pthread #8638

@derofim

Description

@derofim

May be related to #7977 (DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR) and Becavalier/Book-DISO-WebAssembly#10

WEBGL & WASM Threads & shared_memory enabled in browser ( https://github.com/hostilefork/replpad-js/wiki/Enable-WASM-Threads ).
Tested bug in:

  • Firefox Quantum for Ubuntu 65.0.1 (64-bit)
  • Google Chrome Version 74.0.3729.157 (Official Build) (64-bit)
    See emscripten-test-suite result below

Small test code (bash), based on https://github.com/emscripten-core/emscripten/blob/master/tests/webgl2_backwards_compatibility_emulation.cpp :

# test emcc on small app
cd /tmp
# create small app
cat <<EOF >>hello.cpp
#include <GLES3/gl3.h>
#include <GLES2/gl2ext.h>

#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <emscripten.h>
#include <emscripten/html5.h>

EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context;

int main()
{
  EmscriptenWebGLContextAttributes attrs;
  emscripten_webgl_init_context_attributes(&attrs);
  attrs.majorVersion = 2;
  attrs.minorVersion = 0;

  int result = 0;

  EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context(nullptr, &attrs);
  assert(context);
  EMSCRIPTEN_RESULT res = emscripten_webgl_make_context_current(context);
  assert(res == EMSCRIPTEN_RESULT_SUCCESS);
  assert(emscripten_webgl_get_current_context() == context);
  GLuint tex;
  glGenTextures(1, &tex);
  glBindTexture(GL_TEXTURE_2D, tex);
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT_OES, 0);
  assert(glGetError() == 0);
  emscripten_webgl_destroy_context(context);

  return 0;
}
EOF
em++ -s WASM=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=8 -s USE_WEBGL2=1 -s WEBGL2_BACKWARDS_COMPATIBILITY_EMULATION=1 -s GL_ASSERTIONS=1 -s FULL_ES3=1 -s DEMANGLE_SUPPORT=1 -frtti -s SAFE_HEAP=1 -s ALIASING_FUNCTION_POINTERS=0 -s ERROR_ON_MISSING_LIBRARIES=1 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -s ASSERTIONS=2 -s TOTAL_MEMORY=1024MB -s NO_EXIT_RUNTIME=1 -s OFFSCREENCANVAS_SUPPORT=1 -s OFFSCREEN_FRAMEBUFFER=1 -Wall -s USE_SDL=2 -std=c++17 -O1 --emrun -g4 --source-map-base http://localhost:9090/ -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 hello.cpp -o hello.html
# run, & check console for crashes (also check enabled browser flags & browser version)
emrun --port 9090 --serve_root / hello.html

NOTE: with em++ -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=8 -s WASM=1 -s WEBGL2_BACKWARDS_COMPATIBILITY_EMULATION=1 -s NO_EXIT_RUNTIME=1 -s USE_WEBGL2=1 -s GL_ASSERTIONS=1 -s FULL_ES3=1 --emrun -g4 -s DEMANGLE_SUPPORT=1 -frtti -s SAFE_HEAP=1 -s ALIASING_FUNCTION_POINTERS=0 -s ERROR_ON_MISSING_LIBRARIES=1 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -s ASSERTIONS=2 -s TOTAL_MEMORY=1024MB -Wall -std=c++17 -O1 hello.cpp -o hello.html works fine, but adding -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 or -s OFFSCREENCANVAS_SUPPORT=1 == crash

Crash log with DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1:

Starting browser: /usr/bin/xdg-open http://localhost:6931/hello.html
exception thrown: SyntaxError: Failed to execute 'querySelector' on 'Document': The provided selector is empty.,Error: Failed to execute 'querySelector' on 'Document': The provided selector is empty.
    at __findEventTarget (http://localhost:6931/hello.js:2452:101)
    at __findCanvasEventTarget (http://localhost:6931/hello.js:2460:53)
    at _emscripten_webgl_do_create_context (http://localhost:6931/hello.js:2479:20)
    at _emscripten_webgl_create_context (http://localhost:6931/hello.js:2496:10)
    at _main (wasm-function[42]:78)
    at Object.Module._main (http://localhost:6931/hello.js:2921:33)
    at Object.callMain (http://localhost:6931/hello.js:3121:30)
    at doRun (http://localhost:6931/hello.js:3179:60)
    at http://localhost:6931/hello.js:3190:7
^CTraceback (most recent call last):
  File "/home/denis/job/emsc/emsdk/emscripten/1.38.31/emrun", line 9, in <module>
    python_selector.run(__file__)
  File "/home/denis/job/emsc/emsdk/emscripten/1.38.31/tools/python_selector.py", line 24, in run
    sys.exit(subprocess.call([python, os.path.realpath(filename) + '.py'] + sys.argv[1:]))
  File "/usr/lib/python2.7/subprocess.py", line 172, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 1099, in wait
    pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)
  File "/usr/lib/python2.7/subprocess.py", line 125, in _eintr_retry_call
    return func(*args)

Crash log with OFFSCREENCANVAS_SUPPORT=1:

exception thrown: TypeError: Cannot read property 'getContext' of undefined,TypeError: Cannot read property 'getContext' of undefined
    at Object.createContext (http://localhost:6931/hello.js:2619:62)
    at _emscripten_webgl_do_create_context (http://localhost:6931/hello.js:6043:30)
    at _emscripten_webgl_create_context (wasm-function[402]:255)
    at _main (wasm-function[340]:81)
    at Object.Module._main (http://localhost:6931/hello.js:7535:33)
    at Object.callMain (http://localhost:6931/hello.js:7912:30)
    at doRun (http://localhost:6931/hello.js:7970:60)
    at http://localhost:6931/hello.js:7981:7

OFFSCREENCANVAS_SUPPORT seems to be separate issue, browser.test_webgl_offscreen_canvas_in_pthread fails with enabled flags for OFFSCREENCANVAS. Browser prints

--start-- b3a47a9c-047d-48a5-9598-4be3e22e34c1:2:1
oc: [object OffscreenCanvas] b3a47a9c-047d-48a5-9598-4be3e22e34c1:4:1
ctx: [object WebGL2RenderingContext] b3a47a9c-047d-48a5-9598-4be3e22e34c1:6:1
--end--

to small manual js test https://jsfiddle.net/vumyfknb/26/
and even

git clone https://github.com/tgsstdio/webgl2-offscreen-canvas.git
cd webgl2-offscreen-canvas/
npm install
npm run start
http://127.0.0.1:8081/

showed triangles (for some reason, works only in Firefox). So test_webgl_offscreen_canvas_in_pthread seems to be broken, while browser is fine.

Ubuntu 18.04 LTS

emsdk commit: Update tags (#235) 040e49a

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.38.31
clang version 6.0.1 (emscripten 1.38.31 : 1.38.31)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/denis/job/emsc/emsdk/clang/e1.38.31_64bit
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Candidate multilib: .;@m64
Selected multilib: .;@m64
shared:INFO: (Emscripten: Running sanity checks)

emsdk list

The following precompiled tool packages are available for download:
           waterfall-upstream-6285-64bit
           waterfall-fastcomp-6285-64bit
           clang-e1.37.1-64bit      
           clang-e1.38.30-64bit     
     *     clang-e1.38.31-64bit         INSTALLED
           node-4.1.1-32bit         
           node-4.1.1-64bit         
           node-8.9.1-32bit         
     *     node-8.9.1-64bit             INSTALLED
           emscripten-1.30.0        
           emscripten-1.34.1        
           emscripten-1.35.0        
           emscripten-1.37.1        
           emscripten-1.38.30       
     *     emscripten-1.38.31           INSTALLED

The following tools can be compiled from source:
           clang-tag-e1.38.30-32bit 
           clang-tag-e1.38.31-32bit 
           clang-tag-e1.38.30-64bit 
           clang-tag-e1.38.31-64bit 
           clang-incoming-32bit     
           clang-incoming-64bit     
           clang-master-32bit       
           clang-master-64bit       
           upstream-clang-master-32bit
           upstream-clang-master-64bit
           emscripten-tag-1.38.30-32bit
           emscripten-tag-1.38.31-32bit
           emscripten-tag-1.38.30-64bit
           emscripten-tag-1.38.31-64bit
           binaryen-tag-1.38.30-32bit
           binaryen-tag-1.38.31-32bit
           binaryen-tag-1.38.30-64bit
           binaryen-tag-1.38.31-64bit
           emscripten-incoming-32bit
           emscripten-master-32bit  
           emscripten-incoming-64bit
           emscripten-master-64bit  
           binaryen-master-32bit    
           binaryen-master-64bit    

The following precompiled SDKs are available for download: (Run "git pull" followed by "./emsdk update-tags" to pull in the latest list)
         sdk-upstream-6285-64bit  
         sdk-fastcomp-6285-64bit  
         sdk-1.38.30-64bit        
    *    sdk-1.38.31-64bit              INSTALLED

The following SDKs can be compiled from source:
         sdk-incoming-32bit       
         sdk-wasm-master-32bit    
         sdk-incoming-64bit       
         sdk-wasm-master-64bit    
         sdk-master-32bit         
         sdk-master-64bit         
         sdk-tag-1.38.30-32bit    
         sdk-tag-1.38.31-32bit    
         sdk-tag-1.38.30-64bit    
         sdk-tag-1.38.31-64bit

cat /home/denis/.emscripten

import os
LLVM_ROOT = '/home/denis/job/emsc/emsdk/clang/e1.38.31_64bit'
EMSCRIPTEN_NATIVE_OPTIMIZER = '/home/denis/job/emsc/emsdk/clang/e1.38.31_64bit/optimizer'
BINARYEN_ROOT = '/home/denis/job/emsc/emsdk/clang/e1.38.31_64bit/binaryen'
NODE_JS = '/home/denis/job/emsc/emsdk/node/8.9.1_64bit/bin/node'
EMSCRIPTEN_ROOT = '/home/denis/job/emsc/emsdk/emscripten/1.38.31'
SPIDERMONKEY_ENGINE = ''
V8_ENGINE = ''
TEMP_DIR = '/tmp'
COMPILER_ENGINE = NODE_JS
JS_ENGINES = [NODE_JS]

emscripten-test-suite using Python 2.7.15+:

PASSED TESTS:
EMCC_DEBUG=1 python tests/runner.py test_hello_world
EMCC_DEBUG=1 python tests/runner.py browser.test_sdl_image
EMCC_DEBUG=1 python tests/runner.py browser.test_glgears
EMCC_DEBUG=1 python tests/runner.py browser.test_clientside_vertex_arrays_es3
EMCC_DEBUG=1 python tests/runner.py browser.test_gles2_emulation
EMCC_DEBUG=1 python tests/runner.py browser.test_sdl_gl_mapbuffers
EMCC_DEBUG=1 python tests/runner.py browser.test_webgl2
EMCC_DEBUG=1 python tests/runner.py browser.test_webgl2_garbage_free_entrypoints
EMCC_DEBUG=1 python tests/runner.py browser.test_webgl2_backwards_compatibility_emulation
EMCC_DEBUG=1 python tests/runner.py browser.test_webgl_with_closure
EMCC_DEBUG=1 python tests/runner.py browser.test_emscripten_main_loop_and_blocker
EMCC_DEBUG=1 python tests/runner.py browser.test_webgl2_objects
EMCC_DEBUG=1 python tests/runner.py browser.test_webgl2_ubos
EMCC_DEBUG=1 python tests/runner.py browser.test_webgl2_backwards_compatibility_emulation
EMCC_DEBUG=1 python tests/runner.py browser.test_webgl2_packed_types
EMCC_DEBUG=1 python tests/runner.py browser.test_webgl2_pbo
EMCC_DEBUG=1 python tests/runner.py browser.test_webgl_offscreen_framebuffer_state_restoration

FAILED TESTS:
python tests/runner.py sanity

======================================================================
ERROR: test_binaryen (test_sanity.sanity)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/denis/job/emsc/emsdk/emscripten/1.38.31/tests/test_sanity.py", line 901, in test_binaryen
    prep()
  File "/home/denis/job/emsc/emsdk/emscripten/1.38.31/tests/test_sanity.py", line 889, in prep
    config = open(CONFIG_FILE).read()
IOError: [Errno 2] No such file or directory: '/home/denis/.emscripten'

======================================================================
FAIL: test_emcc_caching (test_sanity.sanity)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/denis/job/emsc/emsdk/emscripten/1.38.31/tests/test_sanity.py", line 506, in test_emcc_caching
    self.assertIn(ERASING_MESSAGE, output)
AssertionError: 'clearing cache' not found in 'cache:INFO: generating system asset: is_vanilla.txt... (this will be cached in "/home/denis/.emscripten_cache/is_vanilla.txt" for subsequent builds)\ncache:INFO:  - ok\nshared:WARNING: LLVM version appears incorrect (seeing "6.0", expected "9.0")\nshared:INFO: (Emscripten: Running sanity checks)\nemcc:WARNING: no input files\n'

======================================================================
FAIL: test_firstrun (test_sanity.sanity)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/denis/job/emsc/emsdk/emscripten/1.38.31/tests/test_sanity.py", line 180, in test_firstrun
    self.assertContained('Welcome to Emscripten!', output)
  File "/home/denis/job/emsc/emsdk/emscripten/1.38.31/tests/runner.py", line 721, in assertContained
    additional_info
AssertionError: Expected to find 'Welcome to Emscripten!' in 'shared:ERROR: File /home/denis/.emscripten passed to --em-config does not exist!
', diff:

--- expected
+++ actual
@@ -1 +1,2 @@
-Welcome to Emscripten!
+shared:ERROR: File /home/denis/.emscripten passed to --em-config does not exist!
+



----------------------------------------------------------------------
Ran 20 tests in 403.124s

FAILED (failures=2, errors=1, skipped=1)

EMCC_DEBUG=1 python tests/runner.py browser.test_webgl_offscreen_canvas_in_pthread

======================================================================
FAIL: test_webgl_offscreen_canvas_in_pthread (test_browser.browser)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/denis/job/emsc/emsdk/emscripten/1.38.31/tests/test_browser.py", line 116, in decorated
    return f(self)
  File "/home/denis/job/emsc/emsdk/emscripten/1.38.31/tests/test_browser.py", line 4052, in test_webgl_offscreen_canvas_in_pthread
    self.btest('gl_in_pthread.cpp', expected='1', args=args + ['-s', 'USE_PTHREADS=1', '-s', 'PTHREAD_POOL_SIZE=2', '-s', 'OFFSCREENCANVAS_SUPPORT=1', '-lGL', '-s', 'DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1'])
  File "/home/denis/job/emsc/emsdk/emscripten/1.38.31/tests/runner.py", line 1438, in btest
    self.run_browser(outfile + url_suffix, message, ['/report_result?' + e for e in expected], timeout=timeout)
  File "/home/denis/job/emsc/emsdk/emscripten/1.38.31/tests/runner.py", line 1273, in run_browser
    self.assertIdentical(expectedResult, output)
  File "/home/denis/job/emsc/emsdk/emscripten/1.38.31/tests/runner.py", line 701, in assertIdentical
    limit_size(''.join([a.rstrip() + '\n' for a in difflib.unified_diff(x.split('\n'), y.split('\n'), fromfile='expected', tofile='actual')]))
AssertionError: Expected to have '/report_result?1' == '[no http server activity]', diff:

--- expected
+++ actual
@@ -1 +1 @@
-/report_result?1
+[no http server activity]


----------------------------------------------------------------------
Ran 1 test in 22.157s

FAILED (failures=1)

same with EMTEST_BROWSER=/usr/bin/firefox and chrome

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions