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
Add possibility for disabling inlining wasm
in opencv.js
#23344
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,6 +180,8 @@ def get_build_flags(self): | |
flags += "-s WASM=1 " | ||
elif self.options.disable_wasm: | ||
flags += "-s WASM=0 " | ||
if not self.options.disable_single_file: | ||
flags += "-s SINGLE_FILE=1 " | ||
if self.options.threads: | ||
flags += "-s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 " | ||
else: | ||
|
@@ -233,6 +235,7 @@ def build_loader(self): | |
parser.add_argument('--emscripten_dir', default=emscripten_dir, help="Path to Emscripten to use for build (deprecated in favor of 'emcmake' launcher)") | ||
parser.add_argument('--build_wasm', action="store_true", help="Build OpenCV.js in WebAssembly format") | ||
parser.add_argument('--disable_wasm', action="store_true", help="Build OpenCV.js in Asm.js format") | ||
parser.add_argument('--disable_single_file', action="store_true", help="Do not merge JavaScript and WebAssembly into one single file") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it make sense highlight wasm in the flag naming. Something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. However, origin option is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree, pros and cons, no strong opinion from my side on argument name 🙂 If we are to move away from Happy to modify the PR if you decide on some other name instead of |
||
parser.add_argument('--threads', action="store_true", help="Build OpenCV.js with threads optimization") | ||
parser.add_argument('--simd', action="store_true", help="Build OpenCV.js with SIMD optimization") | ||
parser.add_argument('--build_test', action="store_true", help="Build tests") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this approach fix this issue as well? #21431. Which size reduction do you observe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.js
.wasm
file: 170 kB.js
+ 6.43 MB.wasm
I.e. bundling the generated webassembly code with
base64
is ~32-33 % larger in total compared with separate.wasm
file (consistent with typicalbase64
encoding size increases).