Xamarincommunitytoolkit: [Bug] MediaElement crash when trying to play on iOS ( removing status observer error )

Created on 17 Nov 2020  路  6Comments  路  Source: xamarin/XamarinCommunityToolkit

Description

MediaElement crashes when trying to play video

Steps to Reproduce

  1. Create a page with a MediaElement tag
<xct:MediaElement x:Name="VideoPlayer" Source="{Binding Url}" ShowsPlaybackControls="True" IsLooping="False" MediaEnded="VideoPlayer_MediaEnded" AutoPlay="True" />

(In my case I have a PopupPage from Rg.Plugins.Popup, but I don't think that is the issue)

  1. Open the page
await PopupNavigation.Instance.PushAsync(page);

Expected Behavior

MediaElement opens and plays normally

Actual Behavior

App crashes with an exception when video is about to play.

Exception thrown and app crashes:
Objective-C exception thrown. Name: NSRangeException Reason: Cannot remove an observer <__XamarinObjectObserver 0x282bd7a00> for the key path "status" from because it is not registered as an observer.

Basic Information

  • Version with issue: 1.0.0-preview1022

  • Platform Target Frameworks:

    • iOS: 12.4.9
  • Nuget Packages: Rg.Plugins.Popup

Workaround

I am not aware of any workaround.

I just upgraded from using Xamarin.Forms preview MediaElement to CommunityToolkit,
while XF one had issues, I had my own MediaElementRenderer which worked,
but since I upgraded to CommunityToolkit, my own renderer can't be used because some types are now internal

I can't register on SeekRequested / StateRequested, etc, and I cannot use my own renderer,

Reproduction Link

I may create a blank project to reproduce this issue later if the information above is not sufficient.

MediaElement bug in-progress up-for-grabs

All 6 comments

1.0.0-preview1022 is this correct? Because I see we're up to 1099 now, so would you mind upgrading and see if that fixes it, because I'm pretty sure we fixed this bug :)

my own renderer can't be used because some types are now internal

I can't register on SeekRequested / StateRequested, etc, and I cannot use my own renderer,

So, this is a different issue I guess. Why did you need that renderer? We'd love to take away the need for any renderers

Hi, this version mentioned is the latest available on the nightly nuget sources
https://pkgs.dev.azure.com/xamarin/public/_packaging/XamarinCommunityToolkitNightly/nuget/v3/index.json

should I download sources from github e try linking it manually?

I just thought the nightly would be updated already,
I will try downloading sources and adding them to my project anyway

PS:

I found that I was referencing
Microsoft.Toolkit.Xamarin.Forms

instead of

Xamarin.Community.Toolkit

(both available under the specified nuget repository)

I've got the exact same error:

Objective-C exception thrown. Name: NSRangeException Reason: Cannot remove an observer <__XamarinObjectObserver 0x281d92140> for the key path "status" from because it is not registered as an observer.

while using 1.0.0-preview1100

I will try to create a sample project so it can be reproduced

Bug reproduction project

MediaElementObserverCrash.zip

Yeah I'll have to clean up the nightly feed. Sorry about that :)

Could I ask you one more favor? Try the pre5 release on the official nuget from yesterday? Shouldn't be different from that preview1100 that was mentioned, but just to be sure. Thanks!

I tried it

xamarin.forms.5.0.0.1558-pre3
xamarin.communitytoolkit.1.0.0-pre5

An exception error occurs when executing the bind.

Objective-C exception thrown. Name: NSRangeException Reason:
Cannot remove an observer <__XamarinObjectObserver 0x281951060>
for the key path "status" from
because it is not registered as an observer.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mhrastegary77 picture mhrastegary77  路  3Comments

SunnyMukherjee picture SunnyMukherjee  路  3Comments

jBijsterboschNL picture jBijsterboschNL  路  5Comments

varyamereon picture varyamereon  路  4Comments

jfversluis picture jfversluis  路  5Comments