-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Bug] MediaElement Disposing exception when MainPage is changed on iOS #9525
Comments
This is a hypercritical bug for me. This pretty much makes it impossible to use this control/element within any iOS app. As soon as you navigate out of the page be pressing the back button the whole app crashes. Is there a work around for this? Or way to add this to a hotfix release? I think adding this to 4.6 is a really long timeline for something that is hypercritical like this. |
I'm experiencing the same crash with MediaElement. Navigating out of page with player causes a crash. |
I would also like to know if there is a quick and easy workaround for the time being. |
I used @StevenGranados's fix #9531 and still get exception. Managed Stacktrace
I then did protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
return;
///... rest of MediaElementRenderer disposal
///...
} just to make sure it doesn't crash anymore which it doesn't. My steps to reproduce were
I notice these are slightly different than @StevenGranados. |
I'm currently using Octane.Xam.VideoPlayer. That's been working well for me for the time being. |
This change is fixing the crashes on back button for me. In the iOS MediaElementRenderer.cs change this: to this: I did not apply the patch already linked to this bug. |
Ah, I see that the effect of that change I gave was to prevent the setup of the _rateObserver. So the real fix is in the dispose method by changing this: to this: |
Cool @code-hatchery. I will try that fix. |
Yes, this fix works nicely for me. 👍 |
I confirmed that this bug happens when When Reproduction Steps
Stack Trace at <unknown> <0xffffffff>
at ObjCRuntime.Messaging:void_objc_msgSend <0x000e9>
at AVFoundation.AVPlayer:Pause <0x00122>
at Xamarin.Forms.Platform.iOS.MediaElementRenderer:Dispose <0x00253>
at Foundation.NSObject:Dispose <0x00074>
at Xamarin.Forms.Platform.iOS.VisualElementPackager:Dispose <0x002c5>
at Xamarin.Forms.Platform.iOS.VisualElementPackager:Dispose <0x00071>
at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1:Dispose <0x0024a>
at Foundation.NSObject:Dispose <0x00074>
at Xamarin.Forms.Platform.iOS.VisualElementPackager:Dispose <0x002c5>
at Xamarin.Forms.Platform.iOS.VisualElementPackager:Dispose <0x00071>
at Xamarin.Forms.Platform.iOS.PageRenderer:Dispose <0x0041a>
at Foundation.NSObject:Dispose <0x00074>
at Xamarin.Forms.Platform.iOS.DisposeHelpers:DisposeModalAndChildRenderers <0x0030f>
at <Xamarin-Forms-INavigation-PopModalAsync>d__25:MoveNext <0x008d2>
at MoveNextRunner:InvokeMoveNext <0x000ab>
at System.Threading.ExecutionContext:RunInternal <0x00585>
at System.Threading.ExecutionContext:Run <0x00092>
at MoveNextRunner:Run <0x001aa>
at System.Threading.Tasks.AwaitTaskContinuation:InvokeAction <0x00093>
at System.Threading.Tasks.AwaitTaskContinuation:RunCallback <0x00153>
at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation:Run <0x0013a>
at System.Threading.Tasks.Task:FinishContinuations <0x006a6>
at System.Threading.Tasks.Task:FinishStageThree <0x0015a>
at System.Threading.Tasks.Task`1:TrySetResult <0x0022a>
at System.Threading.Tasks.TaskCompletionSource`1:TrySetResult <0x00092>
at System.Threading.Tasks.TaskCompletionSource`1:SetResult <0x0007a>
at <>c__DisplayClass33_0:<DismissViewControllerAsync>b__0 <0x00082>
at SDAction:Invoke <0x00154>
at SDAction:Invoke <0x0010a>
at <unknown> <0xffffffff>
at UIKit.UIApplication:UIApplicationMain <0x00259>
at UIKit.UIApplication:Main <0x000b2>
at UIKit.UIApplication:Main <0x00132>
at MediaElementRepro.iOS.Application:Main <0x0007a>
at <Module>:runtime_invoke_void_object <0x00198> |
I have also observed the video continuing to play but UI becomes totally unresponsive,. |
Any update on this? Bit of a blocking bug for us. |
Any updates on this bug? I'm having the same issue on ios when I click back to go to the previous page, the UI becomes unresponsive. |
@Az6bcn Have you tried Changing to this: in the MediaElement renderer for iOS? |
I too am blocked with this @samhouts . @Saturn, what do you mean "changing the MediaElement renderer"? Are you suggesting there is a way to get the repo for just the MediaElement and we add that to our project? I thought you could get the repo for all of Forms or none. Or am I missing what you mean with your comment to @Az6bcn? I also note that @brminnick 's repo has been removed. |
Hi @rodhemphill , I copied the MediaElementRenderer from https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.iOS/Renderers/MediaElementRenderer.cs Added it to my Xamarin iOS project, changed the class name to MediaElementRenderer2 and added [assembly: ExportRenderer(typeof(MediaElement), typeof(MediaElementRenderer2))] above namespace. You possibly do not need to change name of class. I then just changed the Dispose method slightly based on @code-hatchery suggestion _rateObserver.Dispose(); to this: _avPlayerViewController?.Player?.RemoveObserver(_rateObserver, "rate"); This allowed me to use the MediaElement on iOS without the crashing issue. I really would hope the fix goes in sooner rather than later because this is just a quick workaround that worked for me. |
@rodhemphill Thanks for the heads up! The repro link should work now: https://github.com/brminnick/MediaElementRepro |
Hi All, In iOS version of my app, when I navigate back from a page that has MediaManager, I get an error in the output which is indicating that the dispose is not called. As a result my app becomes totally non responsive. Do we have to call Dispose method on MediaManager explicitly in iOS Platform project or in Shared project ? [ this is not an issue with Android ] iOS[57831:4538755] Warning: observer object was not disposed manually with Dispose() ================================================================= Basic Fault Address ReportingMemory around native instruction pointer (0x7fff512525f1):0x7fff512525e1 08 5b 41 5e 41 5f 5d c3 48 85 ff 7e 09 48 8b 07 .[A^A_].H..~.H.. ================================================================= Managed Stacktrace:at <0xffffffff> |
Hi @samhouts - is the fix for this issue going to be packaged with XF 4.8 Pre 3 ? |
Incredible solution, Thanks Friend!!!!! |
Description
=================================================================
Native Crash Reporting
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
Native stacktrace:
=================================================================
Basic Fault Address Reporting
Memory around native instruction pointer (0x7fff513fa890):0x7fff513fa880 08 5b 41 5e 41 5f 5d c3 48 85 ff 7e 09 48 8b 07 .[A^A_].H..~.H..
0x7fff513fa890 8a 40 1c 24 01 c3 31 c0 c3 48 85 ff 74 12 78 18 .@.$..1..H..t.x.
0x7fff513fa8a0 48 8b 07 48 85 c0 74 08 48 89 c7 e9 dc c7 00 00 H..H..t.H.......
0x7fff513fa8b0
48 8d 05 6c 09 02 00 c3 48 89 f8 48 c1 e8 3c 48 H..l....H..H..<H
=================================================================
Managed Stacktrace:
.iOS.VisualElementPackager:Dispose <0x002c5>
at Xamarin.Forms.Platform.iOS.VisualElementPackager:Dispose <0x00071>
at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1:Dispose <0x0024a>
at Foundation.NSObject:Dispose <0x00074>
at Xamarin.Forms.Platform.iOS.ListViewRenderer:DisposeSubviews <0x00252>
at Xamarin.Forms.Platform.iOS.ListViewRenderer:DisposeSubviews <0x001a2>
at Xamarin.Forms.Platform.iOS.ListViewRenderer:DisposeSubviews <0x001a2>
at Xamarin.Forms.Platform.iOS.ListViewRenderer:DisposeSubviews <0x001a2>
at Xamarin.Forms.Platform.iOS.ListViewRenderer:Dispose <0x0021a>
at Foundation.NSObject:Dispose <0x00074>
at Xamarin.Forms.Platform.iOS.DisposeHelpers:DisposeModalAndChildRenderers <0x0030f>
at Xamarin.Forms.Platform.iOS.Platform:CleanUpPages <0x0019a>
at Xamarin.Forms.Platform.iOS.PlatformRenderer:Dispose <0x0018a>
at Foundation.NSObject:Dispose <0x00074>
at Xamarin.Forms.Platform.iOS.Platform:Dispose <0x000fa>
at Xamarin.Forms.Platform.iOS.Platform:Syst
em.IDisposable.Dispose <0x00071>
at Xamarin.Forms.Platform.iOS.FormsApplicationDelegate:UpdateMainPage <0x001eb>
at Xamarin.Forms.Platform.iOS.FormsApplicationDelegate:ApplicationOnPropertyChanged <0x000fa>
at Xamarin.Forms.BindableObject:OnPropertyChanged <0x00118>
at Xamarin.Forms.Element:OnPropertyChanged <0x000b2>
at Xamarin.Forms.Application:set_MainPage <0x00417>
at ChatUIXForms.Helpers.Methods:Logout <0x001ea>
at d__7:MoveNext <0x006e2>
at System.Runtime.CompilerServices.AsyncVoidMethodBuilder:Start <0x001be>
at ChatUIXForms.Views.MainPage:LogOut <0x0037a>
at Xamarin.Forms.MenuItem:OnClicked <0x000ab>
at Xamarin.Forms.MenuItem:Xamarin.Forms.IMenuItemController.Activate <0x00183>
at SecondaryToolbarItem:<.ctor>b__1_0 <0x00084>
at UIKit.UIControlEventProxy:Activated <0x000b1>
at System.Object:runtime_invoke_void__this__ <0x000e5>
at <0xffffffff>
at UIKit.UIApplication:UIApplicationMain <0x00259>
at UIKit.UIApplication:Main <0x000b2>
at UIKit.UIApplication:Main <0x00132>
at ChatUIXForms.iOS.Application:Main <0x00092>
at :runtime_invoke_void_object <0x00352>
Steps to Reproduce
Spam new page button in repro.
(In my project's case, just one page change is enough to get the exception)
Expected Behavior
New Page appears with video on it.
Actual Behavior
Video isn't disposed properly.
Basic Information
Reproduction Link
VideoPlayer.zip
The text was updated successfully, but these errors were encountered: