[generator] improve *Implementor constructors #1105
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context: dotnet/maui#12130
Context: https://github.com/angelru/CvSlowJittering
Profiling a .NET MAUI customer sample while scrolling on a Pixel 5, I see ~2.2% of the time spent in:
https://github.com/dotnet/maui/blob/2041476e78452891029f4d2bd806c45be42f4878/src/Core/src/Handlers/View/ViewHandler.Android.cs#L14
MAUI subscribes to
Android.Views.View.FocusChange
for every view placed on the screen -- which happens while scrolling in this sample.Reviewing, the generated code for this constructor still uses the outdated
JNIEnv
APIs:Which we can change to use the newer/faster Java.Interop APIs:
These are better because the equivalent call to
JNIEnv.FindClass()
is cached among other things.After these changes, I instead see:
This should improve the performance of all C# events that wrap Java listeners -- and all .NET MAUI views on Android.
These changes also stop emitting the
[Register]
attribute for*Implementor
classes:Which is not needed, because
*Implementor
classes are generated, internal implementation details.