nw.js
nw.js copied to clipboard
URL.createObjectURL fails on 0.76.1
Issue Type
Before opening an issue, please search and see if it has already been raised.
-
[x] Bug Report
-
[ ] Feature Request
-
[x] Successfully reproduced against the latest version of NW.js?
Please use our mailing list or Gitter chatroom to ask questions. The issue tracker is only for bugs and feature requests, in English only. Please note that issues without a repro or code snippet are less likely to be resolved.
Current/Missing Behavior
URL.createObjectURL(new Blob([]))
is the minimal code needed to reproduce the issue. In 0.76.1 the following error message is produced, regardless of input.
Uncaught TypeError: Failed to execute 'createObjectURL' on 'URL': Overload resolution failed.
Expected/Proposed Behavior
The expected behavior is that a URL to the blob is returned, such as:
blob:chrome-extension://hjnamambhlpahhgnmkmdplebghbjncpm/b1957c09-3e5c-48d3-b545-8052ddb77d3c
This works as expected on 0.75.0.
Additional Info
- Operating System: Windows
- NW.js Version: 0.76.1
- Repro Link:
- Code snippet:
URL.createObjectURL(new Blob([]))
- Crash report:
It works for me. I started nw, opened the devtools window and then posted the snippet.
From my testing, this is only broken inside workers, not on the main thread
-
Worker disabled: https://drive.google.com/file/d/1KO2yJpoG3yo7fXO0i64iWeTAwpZG_5-A/view?usp=drive_link
-
Worker enabled: https://drive.google.com/file/d/1_k4_dQT8B1XWPcjUNGnqAAdNGaMxV330/view?usp=drive_link
(Sorry, file too big for Github)
The bug still happens in 0.77.0
This issue seems to be resolved in 0.78.1
This issue seems to be resolved in 0.78.1
Still failing for me.
Same fail on 0.79.1 win64 Same code works fine on 0.75.1
I have the same problem with pixi.js on 0.79.1 win64 while pixi.js try to load asset
Could you provide a small code sample to reproduce, not an entire application?
I think I found a minimal repro for this: nwjs-issue8075.zip
It's true that URL.createObjectURL(blob)
fails in a worker only in recent versions of NW.js, but only when specifying "chromium-args": "--enable-node-worker"
in package.json, which some frameworks (like ours) do.
In this case, in the context of the worker, the Blob
constructor actually appears to be a version from Node.js (apparently from node:internal/blob
) that overrides the browser one. Therefore since it's not a real Blob that the browser understands, methods like URL.createObjectURL
fail, but also checks like instanceof Blob
also fail.
Hopefully this is enough information to be able to fix the issue now - we're seeing reports of this from time to time (e.g. here).
Any news on this? We are still getting reports of this causing problems, e.g.: https://github.com/Scirra/Construct-bugs/issues/7466
My previous comment includes a minimal repro and appears to identify the --enable-node-worker
command line argument as the problem.
Lỗi 3d object xuất njsw đã được sửa chưa?
Any update on this? We had to disable the worker in our game because of this bug, and now getting lots of reports of poor performance from users..
Has any NW.js developer had the chance to review my minimal repro yet? Tagging @rogerwang for attention. We're still getting regular reports of this, e.g. here and here, both posted today.
Another report of this today here. Any news?
Please test this build: https://dl.nwjs.io/live-build/nw85/20240305-222312/9b99df3ea/v0.85.1/
Thank you, @rogerwang !
@AshleyScirra , I tested in remote preview and it appears to be working. Is it possible to build a C3 project with this new version (85.1)?
@rogerwang - is an official NW.js 0.85.1 release coming up for this? Apparently the issue is affecting some Construct games, and it would be useful to know if a release is scheduled, or if we ought to be using a one-off build (which I'm a bit reluctant about as normally nightly releases are not as reliable)
The fix is released with 0.86.0
@rogerwang - thanks for the fix!
~~By gods! Thank you! This issue was blocking ct.js update to use WebGPU as the issue broke pixi.js v8.~~ Nnope, see the next comment
@rogerwang apparently there are still issues with createObjectURL
. Tested in v0.86.0 and 0.87.0 on Windows.
URL.createObjectURL(new Blob([]))
— throws the same error.
My chromium args are:
"chromium-args": "--mixed-context --enable-features=nw2 --load-extensions --force-color-profile=srgb --disable-features=ColorCorrectRendering",
Edit: removing --mixed-content
fixes the issue (but breaks my app, so it is still an issue)
@rogerwang the same error happens on nw.js-enabled webview
tags. Removing allownw
attribute on them is enough to fix the error — the price is, again, not great.
I think I found a minimal repro for this: nwjs-issue8075.zip
It's true that
URL.createObjectURL(blob)
fails in a worker only in recent versions of NW.js, but only when specifying"chromium-args": "--enable-node-worker"
in package.json, which some frameworks (like ours) do.In this case, in the context of the worker, the
Blob
constructor actually appears to be a version from Node.js (apparently fromnode:internal/blob
) that overrides the browser one. Therefore since it's not a real Blob that the browser understands, methods likeURL.createObjectURL
fail, but also checks likeinstanceof Blob
also fail.Hopefully this is enough information to be able to fix the issue now - we're seeing reports of this from time to time (e.g. here).
Thanks to the error cause analyzed by @AshleyScirra , I found a temporary solution:
<!-- Fix Blob Start -->
<script>delete window.Blob;</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/Blob.min.js"></script>
<!-- Fix Blob End -->
<script>
const objectURL = URL.createObjectURL(new Blob(["test"]));
console.log(objectURL); // 'data:;base64,dGVzdA=='
</script>
But it is still a problem, I hope it can be solved reasonably.