-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix IllegalStateException when closing Duck.ai #6839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| val transaction = supportFragmentManager.beginTransaction() | ||
| transaction.hide(fragment) | ||
| transaction.commit() | ||
| if (!supportFragmentManager.isStateSaved) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how exactly that scenario would play out, but shouldn't this be checked before we run any logic in the function? Otherwise, if a state is restored with fragment visible, our local isDuckChatVisible would be set to false already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It needs to be checked when the animation completes, if we check it before, the state may have changed by then. Not sure how to deal with that inconsistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. Anyway, looks like a quick way to prevent the crash and worst case we'll have a one time issue with keyboard pop-up which will resolve itself either way, so that's not a big deal.
| val transaction = supportFragmentManager.beginTransaction() | ||
| transaction.hide(fragment) | ||
| transaction.commit() | ||
| if (!supportFragmentManager.isStateSaved) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. Anyway, looks like a quick way to prevent the crash and worst case we'll have a one time issue with keyboard pop-up which will resolve itself either way, so that's not a big deal.
This reverts commit ec6e5e5.
Task/Issue URL: https://app.asana.com/1/137249556945/project/1208671518894266/task/1211468322303343?focus=true ### Description Fixes an issue with inaccessible Duck.ai fragment that could happen after failed fragment state transaction. If the Duck.ai close transition finished after `onSaveInstanceState`, the fragment container would be hidden but the fragment itself wouldn't. This led to an invalid state where the app thought the fragment was visible, preventing it from ever re-launching, but its container was `gone`. To resolve the issue, this PR: 1. Allows for lossy fragment transaction when closing Duck.ai. This resolves any potential crashes that #6839 attempted to fix. 2. Checks for fragment and its container state consistency when trying to open Duck.ai. This prevents any state locks in rare cases where activity is restored from saved state after being in Duck.ai mode. ### Steps to test this PR The issue was mostly reproducible for me in `release` variant and with Input Screen enabled, because on New Tab Page the Input Screen reopens after closing Duck.ai fragment which has a higher likelihood of canceling the transitions. - [x] Enable Input Screen. - [x] Open New Tab Page. - [x] Open Input Screen. - [x] Send a prompt to Duck.ai. - [x] Go back and reopen the Input Screen. - [x] Send another prompt to Duck.ai and verify it correctly opens.
Task/Issue URL: https://app.asana.com/1/137249556945/project/488551667048375/task/1211438741846582?focus=true ### Description - Checks `supportFragmentManager.isStateSaved` once the transition has completed to avoid `IllegalStateException` ### Steps to test this PR - [ ] Open Duck.ai - [ ] Close Duck.ai - [ ] Verify that the fragment animates out and hides
Task/Issue URL: https://app.asana.com/1/137249556945/project/1208671518894266/task/1211468322303343?focus=true ### Description Fixes an issue with inaccessible Duck.ai fragment that could happen after failed fragment state transaction. If the Duck.ai close transition finished after `onSaveInstanceState`, the fragment container would be hidden but the fragment itself wouldn't. This led to an invalid state where the app thought the fragment was visible, preventing it from ever re-launching, but its container was `gone`. To resolve the issue, this PR: 1. Allows for lossy fragment transaction when closing Duck.ai. This resolves any potential crashes that #6839 attempted to fix. 2. Checks for fragment and its container state consistency when trying to open Duck.ai. This prevents any state locks in rare cases where activity is restored from saved state after being in Duck.ai mode. ### Steps to test this PR The issue was mostly reproducible for me in `release` variant and with Input Screen enabled, because on New Tab Page the Input Screen reopens after closing Duck.ai fragment which has a higher likelihood of canceling the transitions. - [x] Enable Input Screen. - [x] Open New Tab Page. - [x] Open Input Screen. - [x] Send a prompt to Duck.ai. - [x] Go back and reopen the Input Screen. - [x] Send another prompt to Duck.ai and verify it correctly opens.

Task/Issue URL: https://app.asana.com/1/137249556945/project/488551667048375/task/1211438741846582?focus=true
Description
supportFragmentManager.isStateSavedonce the transition has completed to avoidIllegalStateExceptionSteps to test this PR