New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
opencv_js.worker.js with MODULARIZE generates invalid code #20800
Comments
Details
user@DESKTOP-68JUJRU:~/opencv/emsdk$ python ./opencv/platforms/js/build_js.py --cmake_option="-DCMAKE_TOOLCHAIN_FILE=/home/user/opencv/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" --cmake_option="-DCMAKE_CROSSCOMPILING_EMULATOR=/home/user/opencv/emsdk/node/16.20.0_64bit/bin/node" build_wasm --build_wasm --simd --threads --build_flags=" -s ENVIRONMENT=web,worker "
Args: Namespace(build_dir='build_wasm', opencv_dir='/home/user/opencv/emsdk/opencv', emscripten_dir='/home/user/opencv/emsdk', build_wasm=True, disable_wasm=False, disable_single_file=False, threads=True, simd=True, build_test=False, build_perf=False, build_doc=False, build_loader=False, clean_build_dir=False, skip_config=False, config_only=False, enable_exception=False, cmake_option=['-DCMAKE_TOOLCHAIN_FILE=/home/user/opencv/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake', '-DCMAKE_CROSSCOMPILING_EMULATOR=/home/user/opencv/emsdk/node/16.20.0_64bit/bin/node'], build_flags=' -s ENVIRONMENT=web,worker ', build_wasm_intrin_test=False, config='/home/user/opencv/emsdk/opencv/platforms/js/opencv_js.config.py', webnn=False)
Check dir /home/user/opencv/emsdk/build_wasm (create: True, clean: False)
Check dir /home/user/opencv/emsdk/opencv (create: False, clean: False)
-----------------------------------------------------------
options.opencv_dir: /home/user/opencv/emsdk/opencv
Check dir /home/user/opencv/emsdk (create: False, clean: False)
=====
===== Config OpenCV.js build for wasm
=====
Executing: ['cmake', '-DPYTHON_DEFAULT_EXECUTABLE=/usr/bin/python', '-DENABLE_PIC=FALSE', '-DCMAKE_BUILD_TYPE=Release', "-DCMAKE_TOOLCHAIN_FILE='/home/user/opencv/emsdk/cmake/Modules/Platform/Emscripten.cmake'", "-DCPU_BASELINE=''", '-DCMAKE_INSTALL_PREFIX=/usr/local', "-DCPU_DISPATCH=''", '-DCV_TRACE=OFF', '-DBUILD_SHARED_LIBS=OFF', '-DWITH_1394=OFF', '-DWITH_ADE=OFF', '-DWITH_VTK=OFF', '-DWITH_EIGEN=OFF', '-DWITH_FFMPEG=OFF', '-DWITH_GSTREAMER=OFF', '-DWITH_GTK=OFF', '-DWITH_GTK_2_X=OFF', '-DWITH_IPP=OFF', '-DWITH_JASPER=OFF', '-DWITH_JPEG=OFF', '-DWITH_WEBP=OFF', '-DWITH_OPENEXR=OFF', '-DWITH_OPENGL=OFF', '-DWITH_OPENVX=OFF', '-DWITH_OPENNI=OFF', '-DWITH_OPENNI2=OFF', '-DWITH_PNG=OFF', '-DWITH_TBB=OFF', '-DWITH_TIFF=OFF', '-DWITH_V4L=OFF', '-DWITH_OPENCL=OFF', '-DWITH_OPENCL_SVM=OFF', '-DWITH_OPENCLAMDFFT=OFF', '-DWITH_OPENCLAMDBLAS=OFF', '-DWITH_GPHOTO2=OFF', '-DWITH_LAPACK=OFF', '-DWITH_ITT=OFF', '-DWITH_QUIRC=ON', '-DBUILD_ZLIB=ON', '-DBUILD_opencv_apps=OFF', '-DBUILD_opencv_calib3d=ON', '-DBUILD_opencv_dnn=ON', '-DBUILD_opencv_features2d=ON', '-DBUILD_opencv_flann=ON', '-DBUILD_opencv_gapi=OFF', '-DBUILD_opencv_ml=OFF', '-DBUILD_opencv_photo=ON', '-DBUILD_opencv_imgcodecs=OFF', '-DBUILD_opencv_shape=OFF', '-DBUILD_opencv_videoio=OFF', '-DBUILD_opencv_videostab=OFF', '-DBUILD_opencv_highgui=OFF', '-DBUILD_opencv_superres=OFF', '-DBUILD_opencv_stitching=OFF', '-DBUILD_opencv_java=OFF', '-DBUILD_opencv_js=ON', '-DBUILD_opencv_python2=OFF', '-DBUILD_opencv_python3=OFF', '-DBUILD_EXAMPLES=ON', '-DBUILD_PACKAGE=OFF', '-DBUILD_TESTS=ON', '-DBUILD_PERF_TESTS=ON', '-DCMAKE_TOOLCHAIN_FILE=/home/user/opencv/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake', '-DCMAKE_CROSSCOMPILING_EMULATOR=/home/user/opencv/emsdk/node/16.20.0_64bit/bin/node', '-DBUILD_DOCS=OFF', '-DWITH_PTHREADS_PF=ON', '-DCV_ENABLE_INTRINSICS=ON', '-DBUILD_WASM_INTRIN_TESTS=OFF', "-DCMAKE_C_FLAGS='-s WASM=1 -s SINGLE_FILE=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=8 -msimd128 -s ENVIRONMENT=web,worker '", "-DCMAKE_CXX_FLAGS='-s WASM=1 -s SINGLE_FILE=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=8 -msimd128 -s ENVIRONMENT=web,worker '", '/home/user/opencv/emsdk/opencv']
Re-run cmake no build system arguments
-- Detected processor: x86
-- Looking for ccache - not found
-- Could NOT find OpenJPEG (minimal suitable version: 2.0, recommended version >= 2.3.1). OpenJPEG will be built from sources
-- OpenJPEG: VERSION = 2.5.0, BUILD = opencv-4.8.0-dev-openjp2-2.5.0
-- OpenJPEG libraries will be built from sources: libopenjp2 (version "2.5.0")
-- libva: missing va.h header (VA_INCLUDE_DIR)
-- Module opencv_ts disabled because opencv_imgcodecs dependency can't be resolved!
-- Allocator metrics storage type: 'long long'
-- Excluding from source files list: modules/imgproc/src/corner.avx.cpp
-- Excluding from source files list: modules/imgproc/src/imgwarp.avx2.cpp
-- Excluding from source files list: modules/imgproc/src/imgwarp.lasx.cpp
-- Excluding from source files list: modules/imgproc/src/imgwarp.sse4_1.cpp
-- Excluding from source files list: modules/imgproc/src/resize.avx2.cpp
-- Excluding from source files list: modules/imgproc/src/resize.lasx.cpp
-- Excluding from source files list: modules/imgproc/src/resize.sse4_1.cpp
-- Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': /home/user/opencv/emsdk/opencv/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
-- opencv_dnn: filter out ocl4dnn source code
-- opencv_dnn: filter out cuda4dnn source code
-- Excluding from source files list: modules/dnn/src/layers/cpu_kernels/conv_winograd_f63.neon.cpp
-- Excluding from source files list: /modules/dnn/layers/layers_common.avx.cpp
-- Excluding from source files list: /modules/dnn/layers/layers_common.avx2.cpp
-- Excluding from source files list: /modules/dnn/layers/layers_common.avx512_skx.cpp
-- Excluding from source files list: /modules/dnn/layers/layers_common.rvv.cpp
-- Excluding from source files list: /modules/dnn/layers/layers_common.lasx.cpp
-- Excluding from source files list: /modules/dnn/int8layers/layers_common.avx2.cpp
-- Excluding from source files list: /modules/dnn/int8layers/layers_common.avx512_skx.cpp
-- Excluding from source files list: /modules/dnn/int8layers/layers_common.lasx.cpp
-- Excluding from source files list: /modules/dnn/layers/cpu_kernels/conv_block.avx.cpp
-- Excluding from source files list: /modules/dnn/layers/cpu_kernels/conv_block.avx2.cpp
-- Excluding from source files list: /modules/dnn/layers/cpu_kernels/conv_block.neon.cpp
-- Excluding from source files list: /modules/dnn/layers/cpu_kernels/conv_block.neon_fp16.cpp
-- Excluding from source files list: /modules/dnn/layers/cpu_kernels/conv_depthwise.avx.cpp
-- Excluding from source files list: /modules/dnn/layers/cpu_kernels/conv_depthwise.avx2.cpp
-- Excluding from source files list: /modules/dnn/layers/cpu_kernels/conv_depthwise.rvv.cpp
-- Excluding from source files list: /modules/dnn/layers/cpu_kernels/conv_depthwise.lasx.cpp
-- Excluding from source files list: /modules/dnn/layers/cpu_kernels/conv_winograd_f63.avx.cpp
-- Excluding from source files list: /modules/dnn/layers/cpu_kernels/conv_winograd_f63.avx2.cpp
-- Excluding from source files list: /modules/dnn/layers/cpu_kernels/conv_winograd_f63.neon_fp16.cpp
-- Excluding from source files list: /modules/dnn/layers/cpu_kernels/fast_gemm_kernels.avx.cpp
-- Excluding from source files list: /modules/dnn/layers/cpu_kernels/fast_gemm_kernels.avx2.cpp
-- Excluding from source files list: /modules/dnn/layers/cpu_kernels/fast_gemm_kernels.neon.cpp
-- Excluding from source files list: /modules/dnn/layers/cpu_kernels/fast_gemm_kernels.lasx.cpp
-- Excluding from source files list: modules/features2d/src/fast.avx2.cpp
-- Wrapped in JavaScript(js):
-- opencv_core
-- opencv_imgproc
-- opencv_photo
-- opencv_dnn
-- opencv_features2d
-- opencv_calib3d
-- opencv_objdetect
-- opencv_video
-- Found 'misc' Python modules from /home/user/opencv/emsdk/opencv/modules/python/package/extra_modules
-- Found 'mat_wrapper;utils' Python modules from /home/user/opencv/emsdk/opencv/modules/core/misc/python/package
--
-- General configuration for OpenCV 4.8.0-dev =====================================
-- Version control: 4.8.0-417-g2c1ec4245d-dirty
--
-- Platform:
-- Timestamp: 2023-11-27T14:22:05Z
-- Host: Linux 4.19.128-microsoft-standard x86_64
-- Target: Emscripten 1 x86
-- CMake: 3.22.1
-- CMake generator: Unix Makefiles
-- CMake build tool: /usr/bin/gmake
-- Configuration: Release
--
-- CPU/HW features:
-- Baseline:
--
-- C/C++:
-- Built as dynamic libs?: NO
-- C++ standard: 11
-- C++ Compiler: /home/user/opencv/emsdk/upstream/emscripten/em++ (ver 18.0.0)
-- C++ flags (Release): -s WASM=1 -s SINGLE_FILE=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=8 -msimd128 -s ENVIRONMENT=web,worker -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -pthread -Qunused-arguments -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
-- C++ flags (Debug): -s WASM=1 -s SINGLE_FILE=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=8 -msimd128 -s ENVIRONMENT=web,worker -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -pthread -Qunused-arguments -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
-- C Compiler: /home/user/opencv/emsdk/upstream/emscripten/emcc
-- C flags (Release): -s WASM=1 -s SINGLE_FILE=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=8 -msimd128 -s ENVIRONMENT=web,worker -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -pthread -Qunused-arguments -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
-- C flags (Debug): -s WASM=1 -s SINGLE_FILE=1 -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=8 -msimd128 -s ENVIRONMENT=web,worker -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -pthread -Qunused-arguments -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
-- Linker flags (Release): -Wl,--gc-sections
-- Linker flags (Debug): -Wl,--gc-sections
-- ccache: NO
-- Precompiled headers: NO
-- Extra dependencies:
-- 3rdparty dependencies: zlib libprotobuf quirc
--
-- OpenCV modules:
-- To be built: calib3d core dnn features2d flann imgproc js objdetect photo video
-- Disabled: highgui imgcodecs ml stitching videoio world
-- Disabled by dependency: ts
-- Unavailable: gapi java python2 python3
-- Applications: examples
-- Documentation: js
-- Non-free algorithms: NO
--
-- GUI:
--
-- Media I/O:
-- ZLib: build (ver 1.2.13)
-- JPEG 2000: build (ver 2.5.0)
-- HDR: YES
-- SUNRASTER: YES
-- PXM: YES
-- PFM: YES
--
-- Video I/O:
--
-- Parallel framework: pthreads
--
-- Other third-party libraries:
-- VA: NO
-- Custom HAL: NO
-- Protobuf: build (3.19.1)
-- Flatbuffers: builtin/3rdparty (23.5.9)
--
-- Python (for build): /usr/bin/python
--
-- Install to: /usr/local
-- -----------------------------------------------------------------
--
-- Configuring done
|
i found out that console.log(cv) gives [object Promise] so cv(Module) fails, how should this be handled? |
sorry for spamming: even if cv would be resolved - cv is not a function, so whats the idea behind |
The |
So what's the solution?
|
Does it work if you remove the |
No, it does not work. I tried to get the result of promise and then call |
If you are not using Lines 205 to 211 in 58cf85c
Or is the |
I looked at the logs. This setting is actually set (implicitly, since I did not specify it): Should it be disabled for it to work correctly? |
Well, for sure The real fix is to find out why BTW, I would also try to remove some of those other settings. For example |
Ok, thank you, I'll try to edit default opencv.js settings in |
hi,
when trying to run opencv.js wasm + simd (works) + threads (there it explodes) with this command:
the generated worker code contains this part:
which has the source here:
emscripten/src/worker.js
Line 209 in 58cf85c
i just commented it out, and it works(?)
cv(Module)
callThe text was updated successfully, but these errors were encountered: