Appolica / InteractiveInfoWindowAndroid

Library project, developed and maintained by Appolica, offering an interactive info window for Google maps on Android.
249 stars 56 forks source link

FragmentManager is already executing transactions #20

Closed ddpatel2606 closed 7 years ago

ddpatel2606 commented 7 years ago

I have used your code But I am getting error

"FragmentManager is already executing transactions"

on this line

infoWindowManager.onParentViewCreated(mapViewContainer, savedInstanceState);

this is my stack trace

java.lang.IllegalStateException: FragmentManager is already executing transactions at android.support.v4.app.FragmentManagerImpl.ensureExecReady(FragmentManager.java:1956) at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1980) at android.support.v4.app.BackStackRecord.commitNow(BackStackRecord.java:620) at com.appolica.interactiveinfowindow.InfoWindowManager.onParentViewCreated(InfoWindowManager.java:172) at gtl.com.lotusrestrooms.fragments.MapLocatorFragment.onCreateView(MapLocatorFragment.java:237) at android.support.v4.app.Fragment.performCreateView(Fragment.java:2192) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595) at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758) at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2363) at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2149) at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2103) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2013) at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:763) at gtl.com.lotusrestrooms.activities.TokenActivity.loadFragment(TokenActivity.java:328) at gtl.com.lotusrestrooms.activities.TokenActivity$1$1.run(TokenActivity.java:198) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6121) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)

deangenovski commented 7 years ago

Are you using the MapInfoWindowFragment or are you using the InfoWindowManager directly.

Are you by any chance adding other fragments to the same fragment manager that the InfoWindowManager is using?

At which point does this exception happen?

We will investigate this, meanwhile you can try changing: all commitNow calls in InfoWindowManager to commit.

It could really help us resolve this issue if you could answer the questions above.

We will keep you updated once we have discovered the problem.

ddpatel2606 commented 7 years ago

I have added MapView in my Fragment named as MapInfoWindowFragment

The Map loaded successfully working perfectly & all pins displayed on the map.

But when I click on any info-window & it is opened & trying to load the same fragment again at that time gets crashed.

I have used both options

FragmentManager.executePendingTransactions() & FragmentTransaction.commitNow()

But no success.

ddpatel2606 commented 7 years ago

pls check for more information : https://www.dropbox.com/s/iagqcpsal665k1k/crash.mp4?dl=0

deangenovski commented 7 years ago

Would you mind checking out the github repo and adding the library as a module in android studio and removing the gradle dependency. After that you can try changing: all commitNow calls in InfoWindowManager to commit.

Someone will look into that as soon as we have some availability.

bkolarov-appolica commented 7 years ago

@ddpatel2606 we started working on the problem. For now replacing commit with commitNow in InfoWindowManager.addFragment will fix the crash but will cause another bug because the InfoWindow's view won't be created immediately and we won't know its dimensions to center it.

I suggest you either to use our MapInfoWindowFragment or to encapsulate your MapView in its own separate fragment. There you should pass the child fragment manager to InfoWindowManager. This basically is how MapInfoWindowFragment is implemented. The benefit of this is that the InfoWindowManager will commit its transactions in its own fragment manager, without messing around with transactions that have nothing to do with it.

deangenovski commented 7 years ago

@ddpatel2606 So as @bkolarov-appolica has stated the issue is that you are using the same fragment manager both for the infoWindows and for you general navigation. To solve the problem you are having you need to pass getChildFragmentManager() to the InfoWindowManager when you create it. Or as @bkolarov-appolica has suggested use the encapsulated version - MapInfoWindowFragment

We will close this issue. We can't make due without the commitNow of the transaction because we need the info fragments to become alive immediately so we can get their dimensions. But you really shouldn't be using the same fragment manager for the info windows.

I hope this will help you to solve you problem. Please give us a star if you like our work :)