Xamarin.Forms icon indicating copy to clipboard operation
Xamarin.Forms copied to clipboard

[Bug] TabbedPageRenderer.Dispose() throws FragmentManager is already executing transactions exception

Open maxkoshevoi opened this issue 4 years ago • 6 comments

Note: ~~It's possible that 5.0.0.2012 fixed the issue (Google Play Console didn't find it in four versions in a row. Usually it finds it once per two or three versions)~~ Nope, still happening, just less frequently.

Description

TabbedPageRenderer.Dispose() throws Java.Lang.IllegalStateException: FragmentManager is already executing transactions and app crashes

Steps to Reproduce

It happens very infrequently in this app: https://github.com/maxkoshevoi/NureTimetable I cannot reproduce it locally, so here is what I have:

  • Logs from Google Play Console: logcat (3).txt
  • Stack trace from AppCenter:
Show/Hide stack trace
JniEnvironment+InstanceMethods.CallBooleanMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args)
JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters)
FragmentManager.ExecutePendingTransactions ()
FragmentManagerExtensions.ExecutePendingTransactionsEx (AndroidX.Fragment.App.FragmentManager fragmentManager)
FormsFragmentPagerAdapter`1[T].Dispose (System.Boolean disposing)
IJavaPeerable.Disposed ()
JniRuntime+JniValueManager.DisposePeer (Java.Interop.IJavaPeerable value)
Object.Dispose ()
TabbedPageRenderer.Dispose (System.Boolean disposing)
IJavaPeerable.Disposed ()
JniRuntime+JniValueManager.DisposePeer (Java.Interop.IJavaPeerable value)
Object.Dispose ()
ShellContentFragment.Destroy ()
ShellContentFragment.OnDestroy ()
Fragment.n_OnDestroy (System.IntPtr jnienv, System.IntPtr native__this)
(wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.61(intptr,intptr)
java.lang.IllegalStateException: FragmentManager is already executing transactions
androidx.fragment.app.FragmentManager.ensureExecReady(Unknown Source:94)
androidx.fragment.app.FragmentManager.execPendingActions(Unknown Source:0)
androidx.fragment.app.FragmentManager.executePendingTransactions(Unknown Source:1)
crc643f46942d9dd1fff9.ShellContentFragment.n_onDestroy(Native Method)
crc643f46942d9dd1fff9.ShellContentFragment.onDestroy(Unknown Source:0)
androidx.fragment.app.Fragment.performDestroy(Unknown Source:19)
androidx.fragment.app.FragmentStateManager.destroy(Unknown Source:103)
androidx.fragment.app.FragmentManager.moveToState(Unknown Source:489)
androidx.fragment.app.FragmentManager.moveToState(Unknown Source:2)
androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(Unknown Source:58)
androidx.fragment.app.FragmentManager.moveToState(Unknown Source:47)
androidx.fragment.app.FragmentManager.dispatchStateChange(Unknown Source:9)
androidx.fragment.app.FragmentManager.dispatchDestroy(Unknown Source:10)
androidx.fragment.app.Fragment.performDestroy(Unknown Source:2)
androidx.fragment.app.FragmentStateManager.destroy(Unknown Source:103)
androidx.fragment.app.FragmentManager.moveToState(Unknown Source:489)
androidx.fragment.app.FragmentManager.moveToState(Unknown Source:2)
androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(Unknown Source:58)
androidx.fragment.app.BackStackRecord.executeOps(Unknown Source:171)
androidx.fragment.app.FragmentManager.executeOps(Unknown Source:38)
androidx.fragment.app.FragmentManager.executeOpsTogether(Unknown Source:119)
androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(Unknown Source:84)
androidx.fragment.app.FragmentManager.execPendingActions(Unknown Source:21)
androidx.fragment.app.FragmentManager.executePendingTransactions(Unknown Source:1)
crc643f46942d9dd1fff9.FormsAppCompatActivity.n_onDestroy(Native Method)
crc643f46942d9dd1fff9.FormsAppCompatActivity.onDestroy(Unknown Source:0)
android.app.Activity.performDestroy Activity.java:7684
android.app.Instrumentation.callActivityOnDestroy Instrumentation.java:1306
android.app.ActivityThread.performDestroyActivity ActivityThread.java:4693
android.app.ActivityThread.handleDestroyActivity ActivityThread.java:4731
android.app.servertransaction.DestroyActivityItem.execute DestroyActivityItem.java:39
android.app.servertransaction.TransactionExecutor.executeLifecycleState TransactionExecutor.java:145
android.app.servertransaction.TransactionExecutor.execute TransactionExecutor.java:70
android.app.ActivityThread$H.handleMessage ActivityThread.java:1948
android.os.Handler.dispatchMessage Handler.java:106
android.os.Looper.loop Looper.java:214
android.app.ActivityThread.main ActivityThread.java:7050
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run RuntimeInit.java:494
com.android.internal.os.ZygoteInit.main ZygoteInit.java:965

Expected Behavior

TabbedPageRenderer.Dispose() doesn't throw exception

Actual Behavior

TabbedPageRenderer.Dispose() throws exception and app crashes

Basic Information

  • Version with issue: 5.0.0.2012
  • Last known good version: 4.8 (Shell didn't exist there, so there was no issue)
  • Platform Target Frameworks:
    • iOS:
    • Android: 11
    • UWP:
  • Android Support Library / AndroidX Version:
  • NuGet Packages:
  • Affected Devices:
    • Galaxy M31 (android 10)
    • Galaxy S20 Ultra 5G (android 11)
    • Galaxy Note8 (android 9)
    • Galaxy S8 (android 9)
    • Nokia 1 (android 8.1)

Environment

Show/Hide Visual Studio info
Microsoft Visual Studio Enterprise 2019
Version 16.8.5
VisualStudio.16.Release/16.8.5+31005.135
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Enterprise

Visual C++ 2019   00435-60000-00000-AA437
Microsoft Visual C++ 2019

ASP.NET and Web Tools 2019   16.8.559.8768
ASP.NET and Web Tools 2019

ASP.NET Core Razor Language Services   16.1.0.2052803+84e121f1403378489b842e1797df2f3f5a49ac3c
Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2019   16.8.559.8768
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   16.8.559.8768
Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools   16.8.559.8768
Azure Functions and Web Jobs Tools

C# Tools   3.8.0-5.20604.10+9ed4b774d20940880de8df1ca8b07508aa01c8cd
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Extensibility Message Bus   1.2.6 (master@34d6af2)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

File Icons   2.7
Adds icons for files that are not recognized by Solution Explorer

GitHub.VisualStudio   2.11.106.19330
A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

ILSpy.AddIn   1.0
Integration of the ILSpy Decompiler into Visual Studio.

IntelliCode Extension   1.0
IntelliCode Visual Studio Extension Detailed Info

Markdown Editor   1.12.253
A full featured Markdown editor with live preview and syntax highlighting. Supports GitHub flavored Markdown.

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.30924.1

Microsoft Continuous Delivery Tools for Visual Studio   0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager   2.1.113+g422d40002e.RR
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards   1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio Tools for Containers   1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio   16.8.43 (00471f8)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   5.8.1
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Open Command Line   2.4.233
2.4.233

Project System Tools   1.0
Tools for working with C#, VisualBasic, and F# projects.

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

ResXManager   1.49.4013.0
Manage localization of all ResX-Based resources in one place. Shows all resources of a solution and let's you edit the strings and their localizations in a well-arranged data grid.

Snapshot Debugging Extension   1.0
Snapshot Debugging Visual Studio Extension Detailed Info

SQL Server Data Tools   16.0.62102.01130
Microsoft SQL Server Data Tools

Syntax Visualizer   1.0
An extension for visualizing Roslyn SyntaxTrees.

TypeScript Tools   16.0.21016.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   3.8.0-5.20604.10+9ed4b774d20940880de8df1ca8b07508aa01c8cd
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools   16.8.0-beta.20507.4+da6be68280c89131cdba2045525b80890401defd
Microsoft Visual F# Tools

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Container Tools Extensions   1.0
View, manage, and diagnose containers within Visual Studio.

Visual Studio Tools for Containers   1.0
Visual Studio Tools for Containers

Visual Studio Tools for Unity   4.8.2.0
Visual Studio Tools for Unity

VisualStudio.DeviceLog   1.0
Information about my package

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

Xamarin   16.8.000.262 (d16-8@4d60f9c)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   16.8.0.507 (remotes/origin/d16-8@e87b24884)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates   16.8.112 (86385a3)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK   11.1.0.26 (d16-8/a36ce73)
Xamarin.Android Reference Assemblies and MSBuild support.
    Mono: 5e9cb6d
    Java.Interop: xamarin/java.interop/d16-8@79d9533
    ProGuard: Guardsquare/proguard/proguard6.2.2@ebe9000
    SQLite: xamarin/sqlite/3.32.1@1a3276b
    Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-8@2fb1cbc


Xamarin.iOS and Xamarin.Mac SDK   14.10.0.4 (5a05865f6)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Build Logs

Not related to build

Screenshots

Video from Google Play Console:

Video from Google Play Console

Reproduction Link

Issue happens in this app: https://github.com/maxkoshevoi/NureTimetable

Workaround

None

maxkoshevoi avatar Feb 14 '21 12:02 maxkoshevoi

@maxkoshevoi did you do any workaround for it?

alexandresanlim avatar Mar 14 '22 14:03 alexandresanlim

@alexandresanlim Nope

maxkoshevoi avatar Mar 14 '22 14:03 maxkoshevoi

any updates?

sarboz avatar Jan 16 '23 15:01 sarboz

A have been also receiving quite lot of crash reports with the same exception recently :-(

holecekp avatar Mar 19 '23 20:03 holecekp

The bug is still present. This is the most common cause of crashes in my Xamarin.Forms application according to Google Play reports (the second most common is UnsatisfiedLinkError.)

holecekp avatar May 03 '23 19:05 holecekp

Facing Same Crash when using TabbedPageRender in Xamarin Forms version 5.0.0.2578. Is there any workaround ?

Karkey8 avatar Nov 07 '23 10:11 Karkey8