forked from dotnet/maui
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ios] avoid duplicating
CALayer.Sublayer
arrays (dotnet#21308)
In a customer's application, they saw in Xcode's Instruments: 4.4% Microsoft_Maui_Platform_StokeExtensions_UpdateBackgroundLayer_CoreAnimation_CALayer_CoreGraphics_CGRect > 2.7% CoreAnimation_CALayer_get_Sublayers Reviewing the code, there is a performance problem: if (layer != null && layer.Sublayers != null) { foreach (var sublayer in layer.Sublayers) { //... } } This accesses `CALayer.Sublayers` twice: 1. null check 2. `foreach` When C# calls into Objective-C here, the returned array is marshaled and copied to a C# array that can be consumed in managed code. We are doing this work twice! I audited all calls to `CALayer.Sublayers` and found that we can avoid this in places that are called frequently. This should improve the performance of all views on iOS or Catalyst. However, I don't have access to the customer's application to test the difference. We can have them try a nightly MAUI build after this is merged.
- Loading branch information
1 parent
fde1cff
commit 64deb0f
Showing
7 changed files
with
27 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters