electron: v10.0.0: cannot compile wasm when contextIsolation is enabled

Preflight Checklist

  • [x ] I have read the Contributing Guidelines for this project.
  • [ x] I agree to follow the Code of Conduct that this project adheres to.
  • [ x] I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    • 10.0.0
  • Operating System:
    • macOS 10.14.6
  • Last Known Working Electron version:
    • 9.2.1

Expected Behavior

Wasm should be allowed to compile when contextIsolation is enabled, as it did in v9.2.1.

Actual Behavior

Wasm compilation fails:

Screen Shot 2020-08-25 at 4 24 19 PM

Turning off contextIsolation fixes the problem.

To Reproduce

Screenshots

Additional Information

Note that this error is different from #25066, in which it was clarified that Node is not available to the web page and emscripten when contextIsolation is turned on. In this case, it looks like the browser is not permitting wasm compilation at all.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 15 (12 by maintainers)

Commits related to this issue

Most upvoted comments

@quanglam2807 it hasn’t yet - it needs manual as you can see by the label on the original PR 😃 I do plan to do it when i have time soon tho!

@codebytere Thanks very much for fixing this!

e.g

static bool AllowWasmCodeGenerationCallback(Local<Context> context,
                                            Local<String>) {
  Local<Value> wasm_code_gen =
      context->GetEmbedderData(ContextEmbedderIndex::kAllowWasmCodeGeneration);
  printf("wasm_code_gen->IsUndefined() is: %s\n", wasm_code_gen->IsUndefined() ? "true" : "false");
  printf("wasm_code_gen->IsTrue() is: %s\n", wasm_code_gen->IsTrue() ? "true" : "false");
  printf("wasm_code_gen->IsFalse() is: %s\n", wasm_code_gen->IsFalse() ? "true" : "false");
  printf("wasm_code_gen->IsFunction() is: %s\n", wasm_code_gen->IsFunction() ? "true" : "false");
  printf("wasm_code_gen->IsBoolean() is: %s\n", wasm_code_gen->IsBoolean() ? "true" : "false");
  return wasm_code_gen->IsUndefined() || wasm_code_gen->IsTrue();
}

when contextIsolation: true

false
false
false
true
false

whereas when contextIsolation: false:

false
true
false
false
true

Smaller repro: https://gist.github.com/14159e28f5f3951f99aaebc6de9f7b39

Edit: solved, fix up next week!

@codebytere A stand-alone test is attached in hello.zip that instantiates wasm successfully using v9.2.1 but not v10. To run, unzip and:

/Applications/Electron.app/Contents/MacOS/Electron main.js false    # turn off contextIsolation => success in 9.2.1, 10
/Applications/Electron.app/Contents/MacOS/Electron main.js true     # turn on contextIsolation => fail 10, success 9.2.1

The output will be found in the debugger console window. For success:

Screen Shot 2020-09-04 at 1 07 55 PM

For failure:

Screen Shot 2020-09-04 at 1 07 40 PM

Let me know if I can help further …

hello.zip

I have the same problem when loading Figma with Electron 10.x

Screen Shot 2020-08-27 at 9 15 43 PM