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

[bug] Load image error on Ubuntu. #4496

Closed
Luciennnnnnn opened this issue Jun 28, 2022 · 18 comments
Closed

[bug] Load image error on Ubuntu. #4496

Luciennnnnnn opened this issue Jun 28, 2022 · 18 comments

Comments

@Luciennnnnnn
Copy link

Describe the bug

image
I got this error when I load image on Ubuntu, everything works on Mac and Windows.

Reproduction

No response

Expected behavior

No response

Platform and versions

Environment
  › OS: Ubuntu 20.04 X64
  › Node.js: 16.15.1
  › npm: 8.11.0
  › pnpm: 6.11.0
  › yarn: 1.22.15
  › rustup: 1.24.3
  › rustc: 1.61.0
  › cargo: 1.61.0
  › Rust toolchain: stable-x86_64-unknown-linux-gnu 

Packages
  › @tauri-apps/cli [NPM]: 1.0.0
  › @tauri-apps/api [NPM]: 1.0.1
  › tauri [RUST]: 1.0.0,
  › tauri-build [RUST]: 1.0.0,
  › tao [RUST]: 0.11.2,
  › wry [RUST]: 0.18.3,

App
  › build-type: bundle
  › CSP: default-src 'self' customprotocol: asset: https://asset.localhost; img-src 'self' asset: https://asset.localhost
  › distDir: ../dist
  › devPath: http://localhost:3000/
  › framework: Vue.js

App directory structure
  ├─ src-tauri
  ├─ public
  ├─ dist
  ├─ src
  ├─ .github
  ├─ node_modules
  ├─ lib
  ├─ .git
  └─ .vscode

Stack trace

No response

Additional context

No response

@lucasfernog
Copy link
Member

Can you share how you're loading the asset? Is it a fetch?

@lucasfernog
Copy link
Member

This is a CORS issue - we set the headers on macOS and Windows (that's why it works on those platforms) but webkit2gtk only added support for this recently, so we can't update yet :/

@Luciennnnnnn
Copy link
Author

Can you share how you're loading the asset? Is it a fetch?

I load image using this code:
image

@Luciennnnnnn
Copy link
Author

This is a CORS issue - we set the headers on macOS and Windows (that's why it works on those platforms) but webkit2gtk only added support for this recently, so we can't update yet :/

Is that mean webkit2gtk already supports this? Can tauri update for that?

@lucasfernog
Copy link
Member

We're working to update it - but it's complicated, see #3961

@lucasfernog
Copy link
Member

In your specific case it works if you remove i.crossOrigin = 'Anonymous' @LuoXin-s

@lucasfernog
Copy link
Member

It wouldn't work if you were using fetch() but for video/img tags it works just fine.

@Luciennnnnnn
Copy link
Author

In your specific case it works if you remove i.crossOrigin = 'Anonymous' @LuoXin-s

I remember that if I remove i.crossOrigin = 'Anonymous', there is another problem. that's why I added that. I'll test again and make a response to you.

@Luciennnnnnn
Copy link
Author

We're working to update it - but it's complicated, see #3961

ok

@Luciennnnnnn
Copy link
Author

@lucasfernog If I remove i.crossOrigin = 'Anonymous', I can't export canvas to dataurl. I load image into canvas, and export it to image.
image

@lucasfernog
Copy link
Member

Ahh that's also a CORS issue. If the images are small (and you're not loading several images) you could read the files directly and parse them for the image element but that's.. hard and suboptimal.

@lucasfernog
Copy link
Member

@wusyong do you know if there's a way to disable CORS checks for custom protocols on Linux?

@Luciennnnnnn
Copy link
Author

Ahh that's also a CORS issue. If the images are small (and you're not loading several images) you could read the files directly and parse them for the image element but that's.. hard and suboptimal.

I need to operate many images and they are large usually.

@lucasfernog
Copy link
Member

Reference discussions: #2327 (comment)
tauri-apps/wry#366 (comment)
tauri-apps/wry#348

@lucasfernog
Copy link
Member

lucasfernog commented Jun 28, 2022

@Luciennnnnnn
Copy link
Author

@lucasfernog Hi, any progress on this problem?

@lucasfernog
Copy link
Member

@LuoXin-s Not really :/ I'll need to implement asset protocol functionality inside the tauri protocol.

@wusyong
Copy link
Member

wusyong commented Aug 3, 2022

@wusyong do you know if there's a way to disable CORS checks for custom protocols on Linux?

Sorry I think I missed this mention. There's the updated webkit2gtk but I haven't added because some data race issues.
If you can bring a minimum example to wry. I'll test it along the way.

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

3 participants