Is there an existing issue for this?
Did you read the "Reporting a bug" section on Contributing file?
Current Behavior
Adding MediaElemenet to a page, and then changing the MainPage results in a crash on Android.
I have this on my login page as a background image. Once a user logins i change the MainPage to my actual app. at this point the app crashes.
<toolkit:MediaElement
x:Name="BackgroundVideo"
Aspect="AspectFill"
ShouldAutoPlay="True"
ShouldLoopPlayback="True"
ShouldMute="True"
ShouldShowPlaybackControls="False" />
Something like this is called on successful login:
Application.Current.MainPage = new Page2();
on android, this results in a crash.
<HTML>
<head>
| Name | Value | Type
-- | -- | -- | --
◢ | $exception | {"Exception of type 'Android.Runtime.JavaProxyThrowable' was thrown."} | Android.Runtime.JavaProxyThrowable
| ▶ Cause | null | Java.Lang.Throwable
| ▶ Class | {class android.runtime.JavaProxyThrowable} | Java.Lang.Class
| ▶ Data | Count = 0 | System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
| HResult | -2146233088 | int
| Handle | 0x0000731cfe7d1388 | System.IntPtr
| HelpLink | null | string
| ▶ InnerException (System.Exception) | null | System.Exception
| ▶ InnerException | {"Cannot access disposed object with JniIdentityHashCode=252555712."} | System.Exception {System.ObjectDisposedException}
| JavaStackTrace | "android.runtime.JavaProxyThrowable\n" | string
| JniIdentityHashCode (Java.Interop.JavaException) | 211393919 | int
| JniIdentityHashCode | 211393919 | int
| JniManagedPeerState | None | Java.Interop.JniManagedPeerStates
| LocalizedMessage | "[System.ObjectDisposedException]: Cannot access disposed object with JniIdentityHashCode=252555712.\nObject name: 'CommunityToolkit.Maui.Core.Views.MauiMediaElement'." | string
| Message (System.Exception) | "Exception of type 'Android.Runtime.JavaProxyThrowable' was thrown." | string
| Message | "[System.ObjectDisposedException]: Cannot access disposed object with JniIdentityHashCode=252555712.\nObject name: 'CommunityToolkit.Maui.Core.Views.MauiMediaElement'." | string
| ▶ PeerReference (Java.Interop.JavaException) | {Java.Interop.JniObjectReference} | Java.Interop.JniObjectReference
| Source | "Mono.Android.Runtime" | string
| StackTrace | "\n --- End of managed Android.Runtime.JavaProxyThrowable stack trace ---\nandroid.runtime.JavaProxyThrowable\n" | string
| TargetSite | null | System.Reflection.MethodBase
| is_generated | false | bool
| ▶ Static members | |
| ▶ Non-Public members | |
Android.Runtime.JavaProxyThrowable
HResult=0x80131500
Source=
StackTrace:
An unhandled exception of type 'Android.Runtime.JavaProxyThrowable' occurred in Mono.Android.Runtime.dll
07-11 17:46:33.945 D/AndroidRuntime(17216): Shutting down VM
07-11 17:46:33.946 E/AndroidRuntime(17216): FATAL EXCEPTION: main
07-11 17:46:33.946 E/AndroidRuntime(17216): Process: com.companyname.mediaplayersample, PID: 17216
07-11 17:46:33.946 E/AndroidRuntime(17216): android.runtime.JavaProxyThrowable: [System.ObjectDisposedException]: Cannot access disposed object with JniIdentityHashCode=252555712.
07-11 17:46:33.946 E/AndroidRuntime(17216): Object name: 'CommunityToolkit.Maui.Core.Views.MauiMediaElement'.
07-11 17:46:33.946 E/AndroidRuntime(17216): at Java.Interop.JniPeerMembers.AssertSelf + 0x1e(Unknown Source)
07-11 17:46:33.946 E/AndroidRuntime(17216): at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod + 0x0(Unknown Source)
07-11 17:46:33.946 E/AndroidRuntime(17216): at Android.Views.ViewGroup.RemoveView + 0x27(Unknown Source)
07-11 17:46:33.946 E/AndroidRuntime(17216): at Microsoft.Maui.WindowOverlay.DeinitializePlatformDependencies(/_/src/Core/src/WindowOverlay/WindowOverlay.Android.cs:86)
07-11 17:46:33.946 E/AndroidRuntime(17216): at Microsoft.Maui.WindowOverlay.Deinitialize(/_/src/Core/src/WindowOverlay/WindowOverlay.cs:90)
07-11 17:46:33.946 E/AndroidRuntime(17216): at Microsoft.Maui.VisualDiagnosticsOverlay.Deinitialize(/_/src/Core/src/VisualDiagnostics/VisualDiagnosticsOverlay.cs:186)
07-11 17:46:33.946 E/AndroidRuntime(17216): at Microsoft.Maui.Handlers.WindowHandler.OnRootViewChanged(/_/src/Core/src/Handlers/Window/WindowHandler.Android.cs:92)
07-11 17:46:33.946 E/AndroidRuntime(17216): at Microsoft.Maui.Platform.NavigationRootManager.OnWindowContentPlatformViewCreated(/_/src/Core/src/Platform/Android/Navigation/NavigationRootManager.cs:129)
07-11 17:46:33.946 E/AndroidRuntime(17216): at Microsoft.Maui.Platform.NavigationRootManager+ElementBasedFragment.OnViewCreated(/_/src/Core/src/Platform/Android/Navigation/NavigationRootManager.cs:234)
07-11 17:46:33.946 E/AndroidRuntime(17216): at AndroidX.Fragment.App.Fragment.n_OnViewCreated_Landroid_view_View_Landroid_os_Bundle_(C:\a\_work\1\s\generated\androidx.fragment.fragment\obj\Release
et10.0-android\generated\src\AndroidX.Fragment.App.Fragment.cs:3300)
07-11 17:46:33.946 E/AndroidRuntime(17216): at crc6452ffdc5b34af3a0f.NavigationRootManager_ElementBasedFragment.n_onViewCreated(Native Method)
07-11 17:46:33.946 E/AndroidRuntime(17216): at crc6452ffdc5b34af3a0f.NavigationRootManager_ElementBasedFragment.onViewCreated(NavigationRootManager_ElementBasedFragment.java:36)
07-11 17:46:33.946 E/AndroidRuntime(17216): at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:3152)
07-11 17:46:33.946 E/AndroidRuntime(17216): at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:608)
07-11 17:46:33.946 E/AndroidRuntime(17216): at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:286)
07-11 17:46:33.946 E/AndroidRuntime(17216): at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2214)
07-11 17:46:33.946 E/AndroidRuntime(17216): at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2115)
07-11 17:46:33.946 E/AndroidRuntime(17216): at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:2052)
07-11 17:46:33.946 E/AndroidRuntime(17216): at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:703)
07-11 17:46:33.946 E/AndroidRuntime(17216): at android.os.Handler.handleCallback(Handler.java:942)
07-11 17:46:33.946 E/AndroidRuntime(17216): at android.os.Handler.dispatchMessage(Handler.java:99)
07-11 17:46:33.946 E/AndroidRuntime(17216): at android.os.Looper.loopOnce(Looper.java:201)
07-11 17:46:33.946 E/AndroidRuntime(17216): at android.os.Looper.loop(Looper.java:288)
07-11 17:46:33.946 E/AndroidRuntime(17216): at android.app.ActivityThread.main(ActivityThread.java:7892)
07-11 17:46:33.946 E/AndroidRuntime(17216): at java.lang.reflect.Method.invoke(Native Method)
07-11 17:46:33.946 E/AndroidRuntime(17216): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
07-11 17:46:33.946 E/AndroidRuntime(17216): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Expected Behavior
app should not crash
Steps To Reproduce
- Open and run solution
- Click button
Link to public reproduction project repository
https://github.com/ssbssb-cmd/MediaPlayerSampleCrash
Environment
- .NET MAUI CommunityToolkit:10.0.0
- OS: Windows 11
- .NET MAUI: 10
- .NET MAUI Controls: 10.0.80
Anything else?
No response
Is there an existing issue for this?
Did you read the "Reporting a bug" section on Contributing file?
Current Behavior
Adding MediaElemenet to a page, and then changing the MainPage results in a crash on Android.
I have this on my login page as a background image. Once a user logins i change the MainPage to my actual app. at this point the app crashes.
Something like this is called on successful login:
on android, this results in a crash.
Android.Runtime.JavaProxyThrowable
HResult=0x80131500
Source=
StackTrace:
Expected Behavior
app should not crash
Steps To Reproduce
Link to public reproduction project repository
https://github.com/ssbssb-cmd/MediaPlayerSampleCrash
Environment
Anything else?
No response