NRE on iOS since 3.6.2+
Summary
Since I've upated to 3.6.4 (coming from 3.6.0) I get an NRE on iOS when I call "MediaPlayer.Play()" method. At the moment when I call Play(), the MediaPlayer object is not null. However afterwards an exception gets thrown (see stacktrace below)
ThreadPool.QueueUserWorkItem(_ =>
{
try
{
MediaPlayer?.Play();
#if DEBUG
EventManager.LogEvent(new()
{
Message = $"WebCam => Start playing: State of mediaplayer => {MediaPlayer?.Media?.State}"
});
#endif
}
catch (Exception exc)
{
// Log error
EventManager.LogError(exc);
}
});
Minimal project and steps to reproduce
Update Xamarin.Forms to latest version and call `MediaPlayer.Play()´ in code behind.
What is the current bug behavior?
An NRE exception gets thrown afterwards.
It seems that PowerManager
is null. Could also be related with the new Xamarin.Forms update
PowerManager.KeepScreenOn = true;
What is the expected correct behavior?
No exception
Relevant logs and/or screenshots
at LibVLCSharp.Forms.Shared.DisplayRequest.RequestActive () [0x00006] in <d68ba14bcc314a9b875e2723485e5058>:0
at LibVLCSharp.Shared.MediaPlayerElement.DeviceAwakeningManager.SetDeviceActive (System.Boolean value) [0x00019] in <75101d4265cc4995b6c4fd4ca3a09f5f>:0
at LibVLCSharp.Shared.MediaPlayerElement.DeviceAwakeningManager.UpdateState () [0x00022] in <75101d4265cc4995b6c4fd4ca3a09f5f>:0
at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSAction.cs:152
--- End of stack trace from previous location where exception was thrown ---
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.Type principalClass, System.Type delegateClass) [0x00047] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:79
at KlipperRemoteControl.iOS.Application.Main (System.String[] args) [0x0000d] in C:\KCR\source\KlipperRemoteControl\RCK.iOS\Main.cs:18
Environment
- OS: iOS
- Version: 15.x
- Device: Simulator
- LibVLC version and architecture: 3.6.4, x64
- LibVLCSharp version: Latest
- Xamarin.Forms: 5.0.0.2291
Possible fixes
Downgrading to 3.6.0 fixed it. Also 3.6.1 seems to be fine.