Add DynamicDependency to MauiMediaElement constructors#3116
Conversation
Added [DynamicDependency] to MauiMediaElement constructors to preserve MediaElement public constructors during linking/trimming.
…ng linking. Updated OnDetachedFromWindow to use [DynamicDepedancy]
…android.cs Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>
…ng linking. Updated OnDetachedFromWindow to use [DynamicDepedancy]
|
@pictos I tried removing the |
|
@pictos This as is now fixes the issue that was brought up. The OP has confirmed this fixes it. |
pictos
left a comment
There was a problem hiding this comment.
Just to let you know, this is more a bandwidth than a proper fix. Those constructors are called from Java world when the managed object is collected, so at some point, the code tries to access a disposed MediaElement, would be good to get the stack trace and see the real issue
I agree 100 percent with that. I have already started investigating the issue. I see this as a workaround until a proper fix can be done. I just don't want to leave mediaElement in a non working state for some users. |
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent .NET 10 trimming/linking from removing MediaElement public constructors by adding trimming annotations on the Android MauiMediaElement implementation (to address the Android crash/regression in #3114).
Changes:
- Added
[DynamicDependency(DynamicallyAccessedMemberTypes.PublicConstructors, typeof(MediaElement))]annotations to AndroidMauiMediaElementmembers. - Introduced additional Android
MauiMediaElementconstructor overloads and adjusted the JNI handle constructor to call the appropriate base constructor.
You can also share your feedback on Copilot code review. Take the survey.
|
@ne0rrmatrix is this one ready for review? |
Yes it is ready for review |
…ithub.com/ne0rrmatrix/MauiOld into FixMediaElementParamterlessConstructorBug
pictos
left a comment
There was a problem hiding this comment.
I don't have the green anymore, but it LGTM
Description of Change
Added
[DynamicDependency]toMauiMediaElementconstructors to preserve MediaElement public constructors during linking/trimming.Linked Issues
PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information
Fixes parameter-less constructor error and crash in Android when using
MediaElement.