Skip to content

Remove hash_layout method from Widget trait#1263

Merged
hecrj merged 1 commit into
masterfrom
remove-hash-layout
Feb 23, 2022
Merged

Remove hash_layout method from Widget trait#1263
hecrj merged 1 commit into
masterfrom
remove-hash-layout

Conversation

@hecrj
Copy link
Copy Markdown
Member

@hecrj hecrj commented Feb 23, 2022

This PR removes the hash_layout method from the Widget trait.

This method was added before the very first release of iced for two main reasons:

  1. The layout engine back then was built on top of stretch and was very slow (4ms for basic examples!). However, after Custom layout engine #52 landed, our layout engine is around 1-2 orders of magnitude faster now!
  2. The view logic was executed repeatedly for every single event batch in our event loop and, as such, we needed to consider potential layout changes. After Rebuild widget tree only after an application update #597, we only rebuild the widget tree after a Message is processed. Given that layout cannot change if the widget tree does not change, we only recompute layout in this instance too.

After #52 and #597, the hash_layout method does rarely help improve performance. In fact, given that layout is only recomputed after an update, the resulting hash is likely to be different in almost every case. As a consequence, the runtime is most likely hitting the worst case (hashing + relayout) very often.

In conclusion, we can safely remove the hash_layout method; reducing the Widget surface as a result and slightly improving performance and correctness.

@hecrj hecrj force-pushed the remove-hash-layout branch from 58368fb to 1313c94 Compare February 23, 2022 14:32
@hecrj hecrj merged commit af7cbf0 into master Feb 23, 2022
@hecrj hecrj deleted the remove-hash-layout branch February 23, 2022 15:41
greatest-ape added a commit to greatest-ape/iced_audio that referenced this pull request Mar 18, 2022
Widget::hash_layout was removed in
iced-rs/iced#1263
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant