You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I wrote in #578 when I display a large amount of text in a TextView the application get's slow. Since the problem this issue describes is fixed (sort of) I'm creating a new issue here . I wrote a custom view (mostly copied the TextView code) and then I found out that required_size() is called many times (40+) per second, each time with a different size parameter. Because of this calculate_rows() is called 40+ times per second which than slows down the application. Is there any way to "fix" this?
Here is a part of the log file (the window/view was idle):
The text was updated successfully, but these errors were encountered:
The current caching strategy is a bit brittle as you noticed; requests with conflicting constraints will keep invalidating this cache, blowing up performance. LinearLayout in particular sometimes send such different requests, especially when "constrained" (it cannot give all views the size they want).
We need to improve things here - either make caching more robust, possibly adding a few "historical" cache values, or reduce the number or requests LinearLayout send its children (maybe relying itself on some better cache), or a mix of both.
I now added a few more caches to linear_layout::Child.
This should reduce the number fo requests LinearLayout send it's children
This is the function required_size of linear_layout::Child:
// Compute and caches the required size.
fn required_size(&mut self, req: Vec2) -> Vec2 {
// do we already have the required size calculated and cached?
for size in self.sizes.iter() {
if size.is_some() {
let req_size = size.unwrap().0;
if req_size == req {
return size.unwrap().1;
}
}
}
// if we don't have the size calculated, calculate it and add it to the cache
self.required_size = self.view.required_size(req);
// is the cache full? then remove the last element
if self.sizes.len() == 4 {
self.sizes.pop()
}
self.sizes.insert(0, Some((req, self.required_size)));
self.required_size
}
As I wrote in #578 when I display a large amount of text in a TextView the application get's slow. Since the problem this issue describes is fixed (sort of) I'm creating a new issue here . I wrote a custom view (mostly copied the TextView code) and then I found out that
required_size()
is called many times (40+) per second, each time with a differentsize
parameter. Because of thiscalculate_rows()
is called 40+ times per second which than slows down the application. Is there any way to "fix" this?Here is a part of the log file (the window/view was idle):
The text was updated successfully, but these errors were encountered: