[BUG] Setting Main page crashes when using MediaElement

Abierto
#3,263 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
52/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
android, csharp
Área
mobile

Línea de trabajo

Empieza ejecutando la reproducción vinculada de MediaPlayerSampleCrash y cambiando MainPage después de mostrar MediaElement en Android. Rastrea la ruta de liberación mostrada en el stack trace, especialmente WindowOverlay.DeinitializePlatformDependencies y MauiMediaElement, y verifica que la misma transición se complete sin un Android.Runtime.JavaProxyThrowable ni una ObjectDisposedException.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug unverified
Is there an existing issue for this?
  • I have searched the existing issues
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
  1. Open and run solution
  2. 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

Lenguaje dominante
C#
Estrellas
2.7k
Forks
503
Merge medio
11 h 10 min
PR fusionados (30 d)
50

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de CommunityToolkit/Maui

Todos los issues de CommunityToolkit/Maui

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.