Comments (4)
Okay, so the stack overflow is just... a stack overflow. i.e., this page is very large, and it is all allocated on the stack because the whole thing is statically typed as a bunch of structs and tuples, not Boxes and Vecs. The elements and renderer types are all zero-sized, but even just the strings end up adding up. None of this is implicitly allocated on the heap (by putting it in a Vec<_>
or something), and there are enough nested elements here that the stack is overflowing when you create the tree on that page.
There are several ways to fix this.
- Add some heap allocation of pieces of it by using
.into_any()
. For example, I took one of the<table>
elements, pulled it out separately aslet table = view! { <table>/* a lot of rows */</table> }.into_any()
, and then used{table}
in its place in the view. Overflow solved. - Refactor some of the repeated, identical pieces to use, for example, a
Vec<_>
that you create with.collect_view()
. This will also help your compile times FWIW. So for example, at least one of your tables can be
[("label", "label", "label"), ("other label", "something else", "something else")].into_iter().map(view! { <tr>/* etc */</tr>}).collect_view()`
(This will also save you from having to repeat all the Tailwind classes, etc.)
This did not cause an issue in 0.6 because all children were boxed, and then stored in a Vec, so there were never stack overflows -- but it ended up making a ton of individual heap allocations. A page like this should use much less memory and render much faster with the new system, you just need to break it up into a few pieces so the whole thing doesn't overflow the stack by pushing so much onto it.
from leptos.
Not a joke: It is possible a decent solution here is for us to impl<T> Render for Box<T> where T: Render
, and then for the view macro to insert Boxes around groups of, say, 8 elements or something when they are all children. That's significantly less overhead than .into_any()
in any case.
from leptos.
100% in favour of:
Not a joke: It is possible a decent solution here is for us to impl Render for Box where T: Render, and then for the view macro to insert Boxes around groups of, say, 8 elements or something when they are all children.
:D
from leptos.
Related Issues (20)
- Navigating in/out of `Route` nested in `ParentRoute`s triggering superfluous/duplicate invocation of closures for `Suspense`/`Suspend`. HOT 6
- const support in `#[server]` macro endpoint field HOT 2
- [0.7] Panic on `SSR` refresh when reactive value accessed in `on_cleanup` HOT 2
- [0.7] Store field getters should inherit `pub` modifier from their respective fields HOT 5
- [0.7] Implement `Into<Signal<T>>` & `Into<MaybeSignal<T>>` for stores and their fields HOT 2
- `view!` macro panics when encountering an invalid character literal HOT 2
- [0.7] Panic at HtmlElement::hydrate HOT 3
- [0.7] Suspend inner runs twice, causing double-render of returned View HOT 13
- [0.7] ErrorBoundary doesn't work with Suspend
- Double fetch when starting at `ParamSegment` at some route belonging to `ParentRoute`, navigate to parent and back down
- beta5 problems
- [0.7] Storing a new item in the arena while holding a shared reference to an arena-allocated item fails HOT 2
- [0.7] LocalResources loaded in islands do not trigger Suspense in non-island parents HOT 2
- `Signal<T, S = SyncStorage>` doesn't implement `Track` HOT 5
- [0.7-beta5] Islands hydration issue (unique ID problem) HOT 3
- Double navigation cause desync beetween `Location::pathname` and the actual URL HOT 1
- [0.7] initial state of signal not read for dynamic classes HOT 2
- [0.7] Resource lacks `Debug`
- Compilation failed due to server_fn, no method found HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leptos.