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

strange behavior when ajax local files #167

Closed
KAIYOHUGO opened this issue Oct 19, 2020 · 12 comments
Closed

strange behavior when ajax local files #167

KAIYOHUGO opened this issue Oct 19, 2020 · 12 comments
Labels
bug Something isn't working

Comments

@KAIYOHUGO
Copy link

Describe
when live2d web sdk try to load model.json happend (read log below

To Reproduce
Steps to reproduce the behavior:

  1. use live2d web sdk demo
  2. set as wallpaper
  3. and nothing happen

Expected behavior
when it load model.json throw a error
2020-10-19 15:59:41.6720|INFO|livelywpf.Core.WebProcess|CEF:Fetch API cannot load localfolder://index.html/models/lingbo//lingbo.model3.json. URL scheme "localfolder" is not supported.

Screenshots/Video

  • set as a files
    image

  • set as a web
    image

Desktop (please complete the following information):

  • [ Windows 10 1909] 18363.1082
  • live2d web sdk demo

Additional context
if u set live2d web sdk demo as a web not a local files everything is ok

Log file

2020-10-19 15:59:39.5322|INFO|livelywpf.SetupDesktop|Core: Setting Wallpaper=>index.html
2020-10-19 15:59:40.5434|INFO|livelywpf.SetupDesktop|Sending wallpaper(Per Screen)=>\\.\DISPLAY1 {X=0,Y=0,Width=1920,Height=1080}
2020-10-19 15:59:40.6156|DEBUG|livelywpf.SetupDesktop|Relative Coordinates of WP=>0 1920 1920 1080
2020-10-19 15:59:40.7158|DEBUG|livelywpf.SetupDesktop|Coordinate wrt to screen=>0 0 1920 1080
2020-10-19 15:59:41.6035|INFO|livelywpf.Core.WebProcess|CEF:[CSM][I]Live2D Cubism Core version: 04.00.0000 (67108864)
2020-10-19 15:59:41.6233|INFO|livelywpf.Core.WebProcess|CEF:[CSM][I]CubismFramework.startUp() is complete.
2020-10-19 15:59:41.6397|INFO|livelywpf.Core.WebProcess|CEF:[CSM][I]CubismFramework.initialize() is complete.
2020-10-19 15:59:41.6554|INFO|livelywpf.Core.WebProcess|CEF:[APP]model index: 0
2020-10-19 15:59:41.6720|INFO|livelywpf.Core.WebProcess|CEF:Fetch API cannot load localfolder://index.html/models/lingbo//lingbo.model3.json. URL scheme "localfolder" is not supported.
2020-10-19 15:59:41.6720|INFO|livelywpf.Core.WebProcess|CEF:Uncaught (in promise) TypeError: Failed to fetch
2020-10-19 16:00:55.0286|INFO|livelywpf.Core.Playback|Getting processname failure/handle null, resuming playback!
@KAIYOHUGO KAIYOHUGO added the bug Something isn't working label Oct 19, 2020
@rocksdanister
Copy link
Owner

rocksdanister commented Oct 19, 2020

File access is blocked on browser for security reasons
if u set live2d web sdk demo as a web not a local files everything is ok
By web you mean localhost? if so yes that's how its normally done to get around this.

In cef I'm using its Schemehandler instead of a localhost server:
https://github.com/rocksdanister/lively-cef/blob/a3a5fe81d8e4fd89e1cbc516d486830345fee657/src/cefsharptest/Form1.cs#L446

Looks like its not working correctly in this case 🤔, will need to look over it again.

Is it possible for you to share the wallpaper?

@rocksdanister
Copy link
Owner

rocksdanister commented Oct 20, 2020

Ok, I'll have a look.
(I deleted the comment since the license of the file(s) is not clear.)

Repository owner deleted a comment from KAIYOHUGO Oct 20, 2020
@KAIYOHUGO
Copy link
Author

after testing, i found that error only happen on fetch api 🤔
XMLHttpRequest is OK
and on fetch api u remove protocol (document.location.protocol) not working because it will add itself

i think.....may be add a polyfill that set fetch api to XMLHttpRequest 🤔 💻


test log

fetch("models/lingbo//lingbo.model3.json").then(alert("hi"));
   >>>VM221:1 Fetch API cannot load localfolder://index.html/models/lingbo//lingbo.model3.json. URL scheme "localfolder" is not supported.

@rocksdanister
Copy link
Owner

rocksdanister commented Oct 21, 2020

i think.....may be add a polyfill that set fetch api to XMLHttpRequest

I'm not very familiar with web technologies, let me know if it works.

I'll check the scheme handler code again when I get the time.

In the future, I do plan to add support for Webview2 (Edge) #160 with localhost server when it hits stable(.net version), that should resolve this automatically.

@KAIYOHUGO
Copy link
Author

KAIYOHUGO commented Oct 21, 2020

After testing , it work!🤔


fetch=WHATWGFetch.fetch;

!❗it not the best way to fix it,but it's work❗ !

@rocksdanister
Copy link
Owner

Nah keep it open, this workaround won't be required in the future.

@rocksdanister rocksdanister reopened this Oct 23, 2020
@amaitland
Copy link

Try registered your scheme with IsFetchEnabled set to true.

http://cefsharp.github.io/api/86.0.x/html/P_CefSharp_CefCustomScheme_IsFetchEnabled.htm

@rocksdanister
Copy link
Owner

Thanks, it works now!
Is there any downside having it enabled, seeing how by default its turned off?

@amaitland
Copy link

Great 😄

The built in https scheme has fetch enabled, it's a standard feature. Generally speaking it's fine to enable.

It's not so much as it's deliberately disabled by default, it's more the default wasn't updated when fetch support was added.

@rocksdanister
Copy link
Owner

Got it, appreciate the help.

@rocksdanister
Copy link
Owner

@KAIYOHUGO Beta build is up, you can check if it works:
https://github.com/rocksdanister/lively-beta/releases

@KAIYOHUGO
Copy link
Author

its ok now, tks guys👏👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants