Update performance documentation with latest recommendations
Updates performance guidance per issue #3105: recommend CollectionView over ListView, clarify Shell expectations, add async best practices, and document IDisposable/DI pitfalls.
ListView → CollectionView
- Replaced "Optimize ListView performance" with "Use CollectionView instead of ListView"
- Added warning about placing either control inside
ScrollView/StackLayout(breaks virtualization)
Shell apps clarification
- Added note that Shell is not a universal performance fix—it improves startup by deferring page creation, not other performance issues
Async programming
- Added fire-and-forget anti-pattern guidance: always
awaitasync methods - Removed
Task.Delayrecommendation (not a common perf concern) - Added link to async/await best practices documentation
CollectionView data handling
- Warning about
CollectionViewthrowing on off-threadItemsSourceupdates -
ObservableCollection<T>guidance: preferList<T>for static data; batch updates and reassignItemsSourcefor large datasets
IDisposable and dependency injection
- New subsection warning against registering
IDisposabletypes as transient services (container won't dispose them) - Recommend scoped/singleton services or factory pattern for disposable types
Original prompt
This section details on the original issue you should resolve
<issue_title>Performance document should be updated with latest recommendations</issue_title> <issue_description>### Type of issue
Out of Date Information
Description
- ListView section should tell users to just use CollectionView and we should call out not using it inside a "StackLayout"
- Review these recommendations around image handling
- https://learn.microsoft.com/en-us/dotnet/maui/deployment/performance?view=net-maui-9.0#optimize-image-resources
- Should we put this on the doc? https://learn.microsoft.com/en-us/dotnet/maui/deployment/performance?view=net-maui-9.0#create-shell-apps or possibly add additional context? We don't want to necessarly trigger people to think that converting to shell will magically fix performance issues
- Task suggestions https://learn.microsoft.com/en-us/dotnet/maui/deployment/performance?view=net-maui-9.0#fundamentals
- Should we mention Task.Run? Should this section just refer out to other async/await documentation?
- We should probably add a section about making sure to await everything and never just call an async method
- Review this suggestion "Use the Task.Delay method to produce a Task object that finishes after the specified time. This is useful for scenarios such as polling for data, and delaying handling user input for a predetermined time. For more information, see Task.Delay."
- update this documentation to refer to
CollectionViewand indicate recommendations about not using an ObservableCollection. We should also discourage users from depending on the auto marshalling behavior of CV- Include documentation around
IDisposableand how it shouldn't be used on transient services. https://learn.microsoft.com/en-us/dotnet/maui/deployment/performance?view=net-maui-9.0#release-idisposable-resources https://learn.microsoft.com/en-us/dotnet/core/extensions/dependency-injection-guidelines#recommendationsPage URL
https://learn.microsoft.com/en-us/dotnet/maui/deployment/performance?view=net-maui-9.0
Content source URL
https://github.com/dotnet/docs-maui/blob/main/docs/deployment/performance.md
Document Version Independent Id
5845bd05-2151-862c-9b29-1d76664a9f0d
Platform Id
ed86303e-6644-339a-3af0-abd3ffb65a76
Article author
@davidbritch
Metadata
- ID: 5845bd05-2151-862c-9b29-1d76664a9f0d
- PlatformId: ed86303e-6644-339a-3af0-abd3ffb65a76
- Service: dotnet-mobile
- Sub-service: dotnet-maui
Related Issues</issue_description>
Comments on the Issue (you are @copilot in this section)
- Fixes dotnet/docs-maui#2874
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Internal previews
| 📄 File | 🔗 Preview link |
|---|---|
| docs/deployment/performance.md | docs/deployment/performance |