You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Java.Lang.IllegalStateException: Can not perform this action after onSaveInstanceState on MAUI Blazor (Hybrid) when opened from Android IntentFilter
#19304
Not sure if this is a duplicate of #11501 or not but this does not involve any swapping of Page since there is only one page in MAUI Hybrid (Blazor) app. App simply crashes when opened by Files app with IntentFilter
Add IntentFilter to MainActivity so it can be opened from other apps (like system Files app). Also add LaunchMode to test, it happens to both Standard and SingleTop:
Start debugging the app, app launches with no problem yet.
Swap out of the app and open the Files app, pick any file and open with our app.
Exception is thrown at base.OnCreate(savedInstanceState);, callstack is not helpful:
Java.Lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at Java.Interop.JniEnvironment.InstanceMethods.CallIntMethod(JniObjectReference instance, JniMethodInfo method, JniArgumentValue* args) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/obj/Release/net7.0/JniEnvironment.g.cs:line 20203
at Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeAbstractInt32Method(String encodedMember, IJavaPeerable self, JniArgumentValue* parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:line 492
at AndroidX.Fragment.App.BackStackRecord.Commit() in C:\a\_work\1\s\generated\androidx.fragment.fragment\obj\Release\net6.0-android\generated\src\AndroidX.Fragment.App.BackStackRecord.cs:line 131
at Microsoft.Maui.Platform.NavigationRootManager.SetContentView(IView view) in D:\a\_work\1\s\src\Core\src\Platform\Android\Navigation\NavigationRootManager.cs:line 129
at Microsoft.Maui.Platform.NavigationRootManager.Disconnect() in D:\a\_work\1\s\src\Core\src\Platform\Android\Navigation\NavigationRootManager.cs:line 113
at Microsoft.Maui.Handlers.WindowHandler.DisconnectHandler(NavigationRootManager navigationRootManager) in D:\a\_work\1\s\src\Core\src\Handlers\Window\WindowHandler.Android.cs:line 83
at Microsoft.Maui.Handlers.WindowHandler.OnDisconnectHandler(Object platformView) in D:\a\_work\1\s\src\Core\src\Handlers\Window\WindowHandler.Android.cs:line 67
at Microsoft.Maui.Handlers.ElementHandler.DisconnectHandler(Object platformView) in D:\a\_work\1\s\src\Core\src\Handlers\Element\ElementHandler.cs:line 112
at Microsoft.Maui.Handlers.ElementHandler.Microsoft.Maui.IElementHandler.DisconnectHandler() in D:\a\_work\1\s\src\Core\src\Handlers\Element\ElementHandler.cs:line 130
at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 918
at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 863
at Microsoft.Maui.Platform.ElementExtensions.SetHandler(Context nativeElement, IElement element, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 156
at Microsoft.Maui.Platform.ElementExtensions.SetWindowHandler(Activity platformWindow, IWindow window, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 166
at Microsoft.Maui.Platform.ApplicationExtensions.CreatePlatformWindow(Activity activity, IApplication application, Bundle savedInstanceState) in D:\a\_work\1\s\src\Core\src\Platform\Android\ApplicationExtensions.cs:line 48
at Microsoft.Maui.MauiAppCompatActivity.OnCreate(Bundle savedInstanceState) in D:\a\_work\1\s\src\Core\src\Platform\Android\MauiAppCompatActivity.cs:line 35
at BlazorHybridAndroidIntent.MainActivity.OnCreate(Bundle savedInstanceState) in D:\Github\BlazorHybridAndroidIntent\BlazorHybridAndroidIntent\Platforms\Android\MainActivity.cs:line 24
at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_(IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net8.0/android-34/mcw/Android.App.Activity.cs:line 3082
at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V(_JniMarshal_PPL_V callback, IntPtr jnienv, IntPtr klazz, IntPtr p0) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 125
--- End of managed Java.Lang.IllegalStateException stack trace ---
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at androidx.fragment.app.FragmentManager.checkStateLoss(FragmentManager.java:1632)
at androidx.fragment.app.FragmentManager.enqueueAction(FragmentManager.java:1672)
at androidx.fragment.app.BackStackRecord.commitInternal(BackStackRecord.java:341)
at androidx.fragment.app.BackStackRecord.commit(BackStackRecord.java:306)
at crc647dbdb21fce9310c1.MainActivity.n_onCreate(Native Method)
at crc647dbdb21fce9310c1.MainActivity.onCreate(MainActivity.java:40)
at android.app.Activity.performCreate(Activity.java:8342)
at android.app.Activity.performCreate(Activity.java:8321)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1417)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3625)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3781)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:138)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2306)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7918)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
--- End of managed Java.Lang.IllegalStateException stack trace ---
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at androidx.fragment.app.FragmentManager.checkStateLoss(FragmentManager.java:1632)
at androidx.fragment.app.FragmentManager.enqueueAction(FragmentManager.java:1672)
at androidx.fragment.app.BackStackRecord.commitInternal(BackStackRecord.java:341)
at androidx.fragment.app.BackStackRecord.commit(BackStackRecord.java:306)
at crc647dbdb21fce9310c1.MainActivity.n_onCreate(Native Method)
at crc647dbdb21fce9310c1.MainActivity.onCreate(MainActivity.java:40)
at android.app.Activity.performCreate(Activity.java:8342)
at android.app.Activity.performCreate(Activity.java:8321)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1417)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3625)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3781)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:138)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2306)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7918)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
A MAUI Blazor Template app is the same as a default MAUI Template app, but without Shell as the default entry point. Given that the stacks are the same in all the reproduction cases (even if the direct way of invoking it is different), I think this will be a duplicate of #11501. I think it's the act of changing fragments that's causing it to blow up here. When that's addressed, this issue should be checked again to make sure it works here too, which my suspicion is that it will. If not, it can be reopened.
Description
Not sure if this is a duplicate of #11501 or not but this does not involve any swapping of Page since there is only one page in MAUI Hybrid (Blazor) app. App simply crashes when opened by
Files
app withIntentFilter
Steps to Reproduce
Reproducible project at this repo: https://github.com/datvm/BlazorHybridAndroidIntent
IntentFilter
toMainActivity
so it can be opened from other apps (like system Files app). Also addLaunchMode
to test, it happens to bothStandard
andSingleTop
:base.OnCreate(savedInstanceState);
, callstack is not helpful:Link to public reproduction project repository
https://github.com/datvm/BlazorHybridAndroidIntent
Version with bug
8.0.3
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 13
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: