Skip to content
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

Fix checking if WebAssembly is supported for virtual background #10230

Merged

Conversation

danxuliu
Copy link
Member

@danxuliu danxuliu commented Aug 17, 2023

Before wasm-check 2.1.0 (@ShGKme I knew that the try/catch was there for a reason :-P ) if WebAssembly was disabled in Firefox an exception was thrown when loading wasm-check. However, this was not the expected behaviour, but a bug. The proper way is to check it using support(), which returns false if not supported.

Besides that, when support for using images as a virtual background was added someone :-P forgot that _jitsiStreamBackgroundEffect is not defined when the virtual background is not available. The getter and setter are now guarded in that case, which also requires not using the getter if an object is expected when the virtual background is not available.

I am not sure if this deserves a backport below stable27 🤔 (only for the first and second commits, as the third one fixes a bug introduced in Talk 17)

How to test (scenario 1)

  • In Firefox, open about:config and set javascript.options.wasm to false to disable WebAssembly
  • Open Talk

Result with this pull request

Looks like WebAssembly is disabled or not supported on this browser, virtual background will not be available is logged to the console

Result without this pull request

tflite compilation failed. The web server may not be properly configured to send wasm and/or tflite files. is logged to the console

How to test (scenario 2)

  • Use Firefox
  • Open Talk
  • Start a call to open the device picker
  • Enable a virtual background
  • Open about:config and set javascript.options.wasm to false to disable WebAssembly
  • Reload Talk
  • Start a call to open the device picker

Result with the third commit of this pull request

Microphone and camera are available, although not the virtual background

Result with the second commit of this pull request

No devices are available and this._jitsiStreamBackgroundEffect_ is undefined is logged to the console

"wasmCheck.feature" is always defined, so there is no need to use
optional chaining.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
@danxuliu danxuliu added this to the 💙 Next Major (28) milestone Aug 17, 2023
@danxuliu danxuliu requested a review from ShGKme August 17, 2023 03:02
@danxuliu danxuliu force-pushed the fix-checking-if-webassembly-is-supported-for-virtual-background branch from 49cd6fa to 51d88f8 Compare August 17, 2023 03:03
@danxuliu
Copy link
Member Author

/backport to stable27

@ShGKme
Copy link
Contributor

ShGKme commented Aug 17, 2023

I knew that the try/catch was there for a reason :-P

Sorry 😅

Copy link
Contributor

@ShGKme ShGKme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, works fine. Thanks for fixing it.

Also tested a scenario, when virtual background was set and settings were persisted in LS and then WA was dropped.

src/utils/media/pipeline/VirtualBackground.js Outdated Show resolved Hide resolved
src/utils/media/pipeline/VirtualBackground.js Outdated Show resolved Hide resolved
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Before "wasm-check 2.1.0" if WebAssembly was disabled in Firefox an
exception was thrown when loading "wasm-check". However, this was not
the expected behaviour, but a bug. The proper way is to check it using
"support()", which returns false if not supported.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
If the virtual background is not available
"_jitsiStreamBackgroundEffect" is not even defined, so the public getter
and setter can not delegate to it in that case.

As the getter now returns undefined rather than an actual object the
getter can not be used if an object is expected when the virtual
background is not available.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
@danxuliu danxuliu force-pushed the fix-checking-if-webassembly-is-supported-for-virtual-background branch from 51d88f8 to 78a4028 Compare August 17, 2023 12:39
@ShGKme ShGKme enabled auto-merge August 17, 2023 12:55
@ShGKme ShGKme merged commit fcd7581 into master Aug 17, 2023
@ShGKme ShGKme deleted the fix-checking-if-webassembly-is-supported-for-virtual-background branch August 17, 2023 13:42
@ShGKme ShGKme mentioned this pull request Aug 17, 2023
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants