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

Sketches with assets don't work #12

Open
rbtcollins opened this issue May 10, 2020 · 7 comments
Open

Sketches with assets don't work #12

rbtcollins opened this issue May 10, 2020 · 7 comments

Comments

@rbtcollins
Copy link

E.g. fonts, png's that kind of thing. Sample:

function preload()
{
	background= loadImage('background.png');
}

function setup()
{
	createCanvas(background.width, background.height);
}

function draw()
{
	image(background, 0, 0);
}
@rbtcollins
Copy link
Author

Access to image at 'file:///...' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. [file:///C:/...index.html]

Turns up in the debug console after a while. I don't know if this extension is invoking a chrome under the hood - if so passing --allow-file-access-from-files should fix it.

@filipesabella
Copy link
Owner

Hey there @rbtcollins, thanks for the report! I'll take a look on the weekend.

@filipesabella
Copy link
Owner

I've spent the last couple of hours trying to find a solution, but I don't think there will be one, @rbtcollins :(

In the end there's this github issue and stackoverflow post, and each point to each other hah
https://stackoverflow.com/questions/55841688/vscode-cross-origin-request-inside-webview
microsoft/vscode#72900

Which kinda makes sense, to not allow a random page in a webview to have file access, but it's a bummer.

Perhaps it'd be possible to make it work if the webview loaded a page from, say, localhost:1234 instead of simply a file.

@rbtcollins
Copy link
Author

Perhaps you could layer on the go-live extension? https://github.com/ritwickdey/vscode-live-server Using that works, it is just not embedded in a webview obviously...

@filipesabella
Copy link
Owner

Hey there Collins! Sorry about the delay, I was focussing on this thing the past couple of weekends.

It has its own live server, so I might feel inclined to port the updates on that to this extension. However, if you're feeling really inspired, a PR would be a m a z i n g.

@olgv
Copy link

olgv commented Sep 3, 2021

Unable to preview loading a 3d model. Might be relevant for this thread. Thank you.

@filipesabella
Copy link
Owner

Thanks for the report @olgv.

The problem is still the same: it's a lot of work to port the server code from ProcessingP5 to this extension, and it's bug prone, full-of-corner-cases kinda code.

Until that perhaps eventually gets done, you can use ProcessingP5 with the option to edit code in your own editor, vscode in this case, so you get the auto refresh stuff with loading of files working.

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

No branches or pull requests

3 participants