Commit c2b85d0
authored
Improve perf of AttributedLabel link focus changes and suppress console messages (#565)
This PR mainly fixes two separate things:
1. Performance issues with the focus changes in `AttributedLabel` - Due
to the `frame` property being requested each time the focus is changed,
the code was doing an expensive recalculation of the bounding shape.
This change introduces caching for the bounding shape and only ensures
that the cache is invalidated when the label is updated or when
`layoutSubviews` is called on the label view.
[This](7876c9e)
commit (not being pushed to main) contains the test code that I used for
measuring the performance of this code. In the "before" version, the
frame rate had dropped to ~25 FPS. In the "after" version, the frame
rate is ~110 FPS.
2. Despite using the
[API](https://developer.apple.com/documentation/uikit/uifocusitemcontainer/focusitems(in:))
in the prescribed manner, there would be repeated console output of the
form `_TtCV25BlueprintUICommonControls15AttributedLabel9LabelView
implements focusItemsInRect: - caching for linear focus movement is
limited as long as this view is on screen.` I am able to replicate this
on both iPadOS and tvOS (the platform that Apple had
[originally](https://devstreaming-cdn.apple.com/videos/wwdc/2018/208piymryv9im6/208/208_whats_new_in_tvos_12.pdf)
demonstrated this API on). This change implements the
`_supportsInvalidatingFocusCache()` function similar to how Apple does
it in a number of their system classes such as `UITableView` and
`UICollectionView`, amongst others.
File tree
2 files changed
+81
-1
lines changed- BlueprintUICommonControls/Sources
- SampleApp/Sources
2 files changed
+81
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
214 | 217 | | |
215 | 218 | | |
216 | 219 | | |
| |||
222 | 225 | | |
223 | 226 | | |
224 | 227 | | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
225 | 268 | | |
226 | 269 | | |
227 | 270 | | |
| |||
251 | 294 | | |
252 | 295 | | |
253 | 296 | | |
| 297 | + | |
| 298 | + | |
254 | 299 | | |
255 | 300 | | |
256 | 301 | | |
| |||
644 | 689 | | |
645 | 690 | | |
646 | 691 | | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
647 | 712 | | |
| 713 | + | |
648 | 714 | | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
649 | 724 | | |
650 | 725 | | |
651 | 726 | | |
| |||
674 | 749 | | |
675 | 750 | | |
676 | 751 | | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
677 | 756 | | |
678 | 757 | | |
679 | 758 | | |
| |||
776 | 855 | | |
777 | 856 | | |
778 | 857 | | |
779 | | - | |
| 858 | + | |
780 | 859 | | |
781 | 860 | | |
782 | 861 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
0 commit comments