dioxus-web: AttributeValue::Float uses f64::to_string, pulling ~13 KB of float printing into every web build
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- rust, wasm
- Domain
- performance, web-dev
Research direction
Start in packages/web/src/mutations.rs at the AttributeValue::Float arm and check how the web crate handles JavaScript number conversion and its dependencies. Compare the generated release Wasm size with the current formatting path and the proposed browser formatting path; done means the float attribute uses browser formatting and the build no longer includes float printing solely for this conversion.
Written by the indexing model from the issue text.
Description
packages/web/src/mutations.rs sets float attributes with &f.to_string(), which links core::fmt::float / flt2dec (about 13 KB raw, 8 KB gzip) into every web build, even an app that never sets a decimal attribute (measured with dioxus-web 0.7.10, dx build --release --wasm-split, opt-level = "z", LTO).
Letting the browser format the number avoids it:
AttributeValue::Float(f) => self.interpreter.set_attribute(
id.0 as u32,
name,
- &f.to_string(),
+ &String::from(js_sys::Number::from(*f).to_string(10).unwrap_or_default()),
ns.unwrap_or_default(),
),
The only visible difference is the browser's spelling for extremes (1e+21 and Infinity instead of 1000000000000000000000 and inf), which is what the DOM would show for those values anyway. Happy to open a PR if that's welcome.
- Dominant language
- Rust
- Stars
- 39.8k
- Forks
- 2k
- Avg merge
- 14h 29m
- Merged PRs (30d)
- 20
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from DioxusLabs/dioxus
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
DioxusLabs/dioxus#6095 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 83/100
DioxusLabs/dioxus#6063 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
DioxusLabs/dioxus#6058 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
DioxusLabs/dioxus#6008 ·
Maintainers usually reply within 1 day
-
dioxus-desktop on macOS: Finder file drops never fire `ondrop` — `dragenter` is not cancelledPossibly taken @staging-devin-ai-integration claimed this 23 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
DioxusLabs/dioxus#6006 ·
Maintainers usually reply within 1 day
All issues in DioxusLabs/dioxus
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
longbridge/gpui-kit#4031 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
neuralmagic/crucible#465 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
compiler P3
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
HerringtonDarkholme/hd-lang#2162 ·
Maintainers usually reply within 1 day
-
embedded SQL: pin correlated-guard behaviour when a closed variable is reassigned inside a branchOpenpriority: low
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
jonathanong/no-mistakes#3627 ·
Maintainers usually reply within 1 day