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

URL.createObjectURL fails on 0.76.1 #8075

Closed
2 of 3 tasks
Kruithne opened this issue May 24, 2023 · 22 comments
Closed
2 of 3 tasks

URL.createObjectURL fails on 0.76.1 #8075

Kruithne opened this issue May 24, 2023 · 22 comments
Assignees

Comments

@Kruithne
Copy link

Issue Type

Before opening an issue, please search and see if it has already been raised.

  • Bug Report

  • Feature Request

  • 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:
@rogerwang
Copy link
Member

It works for me. I started nw, opened the devtools window and then posted the snippet.

@skymen
Copy link

skymen commented Jun 12, 2023

From my testing, this is only broken inside workers, not on the main thread

(Sorry, file too big for Github)

The bug still happens in 0.77.0

@Laserwolve
Copy link

This issue seems to be resolved in 0.78.1

@johnyc3
Copy link

johnyc3 commented Aug 30, 2023

This issue seems to be resolved in 0.78.1

Still failing for me.

@anker9
Copy link

anker9 commented Sep 3, 2023

Same fail on 0.79.1 win64
Same code works fine on 0.75.1

@ellementul
Copy link

ellementul commented Sep 18, 2023

I have the same problem with pixi.js on 0.79.1 win64 while pixi.js try to load asset

@rogerwang
Copy link
Member

Could you provide a small code sample to reproduce, not an entire application?

@AshleyScirra
Copy link

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).

@AshleyScirra
Copy link

Any news on this? We are still getting reports of this causing problems, e.g.: Scirra/Construct-bugs#7466
My previous comment includes a minimal repro and appears to identify the --enable-node-worker command line argument as the problem.

@sieusaovang
Copy link

Lỗi 3d object xuất njsw đã được sửa chưa?

@dop2000
Copy link

dop2000 commented Nov 18, 2023

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..

@AshleyScirra
Copy link

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.

@AshleyScirra
Copy link

Another report of this today here. Any news?

@rogerwang
Copy link
Member

Please test this build: https://dl.nwjs.io/live-build/nw85/20240305-222312/9b99df3ea/v0.85.1/

@dop2000
Copy link

dop2000 commented Mar 6, 2024

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)?

@AshleyScirra
Copy link

@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)

@rogerwang
Copy link
Member

The fix is released with 0.86.0

@AshleyScirra
Copy link

@rogerwang - thanks for the fix!

@CosmoMyzrailGorynych

This comment was marked as outdated.

@CosmoMyzrailGorynych
Copy link

CosmoMyzrailGorynych commented May 3, 2024

@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)

@CosmoMyzrailGorynych
Copy link

@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.

@CosmoMyzrailGorynych CosmoMyzrailGorynych moved this from Done to Blocked / Upstream bugs in Overlook May 12, 2024
@ssnangua
Copy link

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).

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests