Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

FragmentManager is already executing transactions #214

Closed
alouanemed opened this issue Mar 12, 2018 · 14 comments · Fixed by #236
Closed

FragmentManager is already executing transactions #214

alouanemed opened this issue Mar 12, 2018 · 14 comments · Fixed by #236

Comments

@alouanemed
Copy link

Caused by: java.lang.IllegalStateException: FragmentManager is already executing transactions
                                                                                     at android.app.FragmentManagerImpl.ensureExecReady(FragmentManager.java:1981)
                                                                                     at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2037)
                                                                                     at android.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:799)
                                                                                     at com.tbruyelle.rxpermissions2.RxPermissions.getRxPermissionsFragment(RxPermissions.java:54)
                                                                                     at com.tbruyelle.rxpermissions2.RxPermissions.<init>(RxPermissions.java:41)
                                                                                     at com......MessagesActivity.initViews(MessagesActivity.java:113)

in this code :

rxPermissions = new RxPermissions(this);

I don't know exactly the reason behind this as it was working before without any issue.

@rogerou
Copy link

rogerou commented Jun 6, 2018

same

@epool
Copy link
Collaborator

epool commented Jul 6, 2018

this should be fixed with #233

@epool epool closed this as completed Jul 6, 2018
@llleodeleon
Copy link

llleodeleon commented Jul 10, 2018

I'm targeting API 27 and I also have this error if I request the permission onViewCreated on a Fragment. What's the workaround? @epool

@chetbox
Copy link

chetbox commented Jul 10, 2018

I have the same issue as @leodeleon22 using version 0.10.1.

Stack trace:

    java.lang.IllegalStateException: FragmentManager is already executing transactions
        at android.support.v4.app.FragmentManagerImpl.ensureExecReady(FragmentManager.java:2179)
        at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2211)
        at android.support.v4.app.BackStackRecord.commitNow(BackStackRecord.java:643)
        at com.tbruyelle.rxpermissions2.RxPermissions.getRxPermissionsFragment(RxPermissions.java:71)
        at com.tbruyelle.rxpermissions2.RxPermissions.access$000(RxPermissions.java:34)
        at com.tbruyelle.rxpermissions2.RxPermissions$1.get(RxPermissions.java:54)
        at com.tbruyelle.rxpermissions2.RxPermissions$1.get(RxPermissions.java:47)
        at com.tbruyelle.rxpermissions2.RxPermissions.pending(RxPermissions.java:205)
        at com.tbruyelle.rxpermissions2.RxPermissions.request(RxPermissions.java:194)
        at com.tbruyelle.rxpermissions2.RxPermissions.access$100(RxPermissions.java:34)
        at com.tbruyelle.rxpermissions2.RxPermissions$2.apply(RxPermissions.java:96)
        at io.reactivex.Observable.compose(Observable.java:6284)
        at com.tbruyelle.rxpermissions2.RxPermissions.request(RxPermissions.java:170)
        at foo.MyFragment.onCreateView(MyFragment.kt:55)
        ...

I tried moving the initialisation to onStart but that gives same error.

@epool
Copy link
Collaborator

epool commented Jul 10, 2018

@leodeleon22 @chetbox now when you instantiate new RxPermissions(this) from a fragment you have to pass the fragment instance instead of the fragment's activity. This is fixed with v0.10.2

@pawegio pawegio mentioned this issue Sep 17, 2018
@guness
Copy link

guness commented Dec 8, 2018

@leodeleon22 @chetbox now when you instantiate new RxPermissions(this) from a fragment you have to pass the fragment instance instead of the fragment's activity. This is fixed with v0.10.2

mate this is bug itself. not the fix.

@kirilamenski
Copy link

kirilamenski commented Feb 21, 2019

Has anyone found solution?

I solved this by running after delay:

new Handler().postDelayed(() -> {
// run rxPermission
}, 1000)

but it is dirty hack

@ronjdaugherty34
Copy link

ronjdaugherty34 commented Apr 4, 2019

The dirty hack works I just added a second debounce to the chain

rxPermissions.requestEachCombined(
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.CALL_PHONE, Manifest.permission.BLUETOOTH
)
.debounce(1, TimeUnit.SECONDS)
.subscribe { permission ->
when {
permission.granted -> {}
permission.shouldShowRequestPermissionRationale -> {}
else -> {}
}
}

@mosentest
Copy link

hi kid

@GensaGames
Copy link

Any ideas, when this bug will be fixed? This is ridicules. You have inside method RxPermission, with could accept Activity, or Fragment. But for Activity it's crashing.

@mrArtCore
Copy link

@GensaGames This is not ridiculous. It's been a long time since a saw the maintainer active in this repository.
Maybe because of such commentators? The community of this repository does nothing just create issues. And if this is the cause of why maintainer is inactive so long I can't blame him. I understand.

But!
Why don't you fix this? Go and create PR, you are welcome!

@GensaGames
Copy link

@mrArtCore I'm sorry for my message tone above.

@mrArtCore
Copy link

@GensaGames
Nice to see your message above! Thanks! Take care !
And how about to fix it ? =))

@relaxedSoul
Copy link

Any ideas, when this bug will be fixed? This is ridicules. You have inside method RxPermission, with could accept Activity, or Fragment. But for Activity it's crashing.

To be honest, I am not sure there is actually a fix. It is the same as calling Activity.startActivityForResult inside Fragment and wait for result in Fragment.onActivityResult.

I mean, the only solution I see is creating annotations to say IDE to count it as a warning with the message.

Just use the right methods in the right places. For me, the fix is made and I use the right constructor in the right place.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.