Closed Enyium closed 1 month ago
This was already reported: https://github.com/slint-ui/slint/issues/4132
slintpad runs on the browser and can load image from the network, while the slint compiler is not fetching files from the network, neither the slint runtime.
The docs are also rendered with the wasm interpreter, and it's an easy way to do preview.
@ogoffart: The console showing an error message, but the preview window not, isn't a bug?!
And SlintPad being able to load files from the network has to do with it using the interpreter?
Yes, Slintpad uses the interpreter internally. No, that has nothing to do with Slintpad being able to load images from URLs:-)
Slintpad runs WASm code, and WASM has no access to any filesystem at all. So we needed to hack something there to load get any data into the interpreter... that hack forwards load requests to the browser and browsers happen to be really good at loading things from the web. It's more an implementation detail than a planned feature ;-)
But don't you think it's confusing to first see @image-url("https://...
in the docs, and then not being able to make use of it? I think this should be mentioned in the docs and in the console error message. And the local preview should show the error message also.
I agree: This is confusing. Most of the time its a relative path, so it is hard to tell whether its a URL or a file path, so we do get away with it rather often.
But yes, that is a problem. The preview and Slintpad should be as close as possible to the "normal" compiler.
The docs page "Syntax > Types > Images" has an example that works in SlintPad when you click "Edit" below the example. But when I copy it under Windows 10 into a Rust project with Slint (not matter whether FemtoVG or Skia), it produces the following error message through
build.rs
'sslint_build::compile()
:It isn't clear why running the example in SlintPad and locally should differ in behavior. If local builds have a limitation regarding URLs, the message should reflect this and lead the developer on their way to understand the reasons and background better.
Also, the error is silent in the preview window shown via "Show Preview" from the VS Code editor. It just shows:
Whereas SlintPad shows: