Description
openedon Jun 10, 2024
Description
Navigating to a page with a CollectionView that uses a complex ItemTemplate freezes the UI for more than 1 sec while the view initializes.
This has been tested in the emulator (where it is not that slow, the view completes in around 300ms), on a Nokia G22 phone, and on a Lenovo TB-J616F tablet, all in Release build.
Test app
Screenshot of test app (see reproduction app link) on start up:
Screenshot of the app after clicking the button:
Profiling
I did some profiling on an actual device. Here's a trace obtained from the repro-app running in Release build on a Nokia G22 phone:
It seems the bulk of time is spent in ContentViewGroup.OnMeasure (and related methods). The trace shows time divided among the ~16 items that fits in the screen.
Related issues
Some related issues are:
Steps to Reproduce
- Create a new MAUI application from standard template with a Shell
- Add a new ContentPage and a button that navigates to the ContentPage
- Add a CollectionView with a complex ItemTemplate (e.g., 6+ labels in a Grid using OneWay bindings)
- Populate the view with a list of items with random generated data
Link to public reproduction project repository
https://github.com/mikkelrj/MauiApp3/
Version with bug
8.0.21 SR4.1
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android, I was not able test on other platforms
Affected platform versions
Android
Did you find any workaround?
Some half-assed workarounds include initializing the view first with a simple template and then when the view has loaded (e.g., in the OnAppeared method) setting the complex template.
The issue remains, though, that the UI will block while the CollectionView is initialized.
Relevant log output
No response