DioxusLabs / DioxusLabs/dioxus
Underterministic Asset Management + Bad Priority Management
- Dominant language
- Rust
- Stars
- 39.1k
- Forks
- 1.9k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
**Problem**
In `packages/cli/src/build/request.rs` at line 4313 (At the date of the issue. That part of code should be easy to grep anyway) there is iteration over a `HashMap`:
```rust
// Inject any resources from manganis into the head
for asset in assets.assets() {
let asset_path = asset.bundled_path();
match asset.options().variant() {
AssetVariant::Css(css_options) => {
if css_options.preloaded() {
head_resources.push_str(&format!(
""
))
}
}
AssetVariant::Image(image_options) => {
if image_options.preloaded() {
head_resources.push_str(&format!(
""
))
}
}
AssetVariant::Js(js_options) => {
if js_options.preloaded() {
head_resources.push_str(&format!(
""
))
}
}
_ => {}
}
}
```
This is not deterministic and causes problems, because `index.html` is changing (order of ``) when nothing else changed. It creates problems for caching and other things.
Additionally, the order of `` tags matters.
> The browser downloads resources with the same computed priority in the order they're discovered.
[fetch-priority]
`wasm` blob is the last ``, so browser would issue a request to `wasm` after all other resources. Browsers are opening only a bounded amount of sockets, and server / connection will not always be as fast, thus `wasm` execution may be delayed - which means execution of the whole application may be delayed (it happens for me too).
```
// Manually inject the wasm file for preloading. WASM currently doesn't support preloading in the manganis asset system
head_resources.push_str(&format!(
""
));
Self::replace_or_insert_before("{style_include}", "` management.
[fetch-priority]: https://web.dev/articles/fetch-priority
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.