Unity 6 alpha Webgl error

As a WebGL platform, Unity 6 version worked normally when built and run, but in Unity 6 alpha version, the following error occurs when built and run.
“Uncaught SyntaxError: Failed to execute ‘querySelector’ on ‘Document’: ‘0’ is not a valid selector.”

I’d like to know why.

1 Like

Hi @mrpsh,

Could you please provide more information about this issue?

The behaviour that you are observing might potentially be a bug in Unity. Could you please submit a bug report with a project?
Here’s the info on how to submit a bug report bug-reporting.

Thank you

Happening to me too, using Unity 6000.0.1f1
the error happens when the loader script tries to load the game,
The browser log is:

Uncaught (in promise) SyntaxError: Failed to execute ‘querySelector’ on ‘Document’: ‘#’ is not a valid selector.

at findEventTarget (f942c931-0c38-4494-943e-8cc6f74e2197:9:166335)
at registerKeyEventCallback (f942c931-0c38-4494-943e-8cc6f74e2197:9:201923)
at _emscripten_set_keydown_callback_on_thread (f942c931-0c38-4494-943e-8cc6f74e2197:9:202252)
at 0a6c7c0e:0x230f64c
at 0a6c7c0e:0x23221cf
at Module._main (f942c931-0c38-4494-943e-8cc6f74e2197:9:326787)
at callMain (f942c931-0c38-4494-943e-8cc6f74e2197:9:328654)
at doRun (f942c931-0c38-4494-943e-8cc6f74e2197:9:329068)
at run (f942c931-0c38-4494-943e-8cc6f74e2197:9:329240)
at runCaller (f942c931-0c38-4494-943e-8cc6f74e2197:9:328354)
at Object.removeRunDependency (f942c931-0c38-4494-943e-8cc6f74e2197:9:9885)
at MyWebGLGame_U6000.loader.js:1:116500

Opening the script, its at:

function findEventTarget(target) {
    target = maybeCStringToJsString(target);
    var domElement = specialHTMLTargets[target] || document.querySelector(target); <-- HERE
    return domElement
}

My problem got fixed, it was due to wrongly using the querySelector to get the Canvas element and pass it to the createUnityInstance function.