Skip to content

Conversation

@joshliebe
Copy link
Contributor

@joshliebe joshliebe commented Sep 24, 2025

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

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@0nko 0nko self-assigned this Sep 24, 2025
val transaction = supportFragmentManager.beginTransaction()
transaction.hide(fragment)
transaction.commit()
if (!supportFragmentManager.isStateSaved) {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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) {
Copy link
Contributor

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.

@joshliebe joshliebe merged commit ec6e5e5 into develop Sep 24, 2025
20 of 21 checks passed
@joshliebe joshliebe deleted the feature/josh/fix-close-duck-chat-crash branch September 24, 2025 12:49
LukasPaczos added a commit that referenced this pull request Sep 25, 2025
joshliebe pushed a commit that referenced this pull request Sep 26, 2025
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.
karlenDimla pushed a commit that referenced this pull request Sep 26, 2025
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
karlenDimla pushed a commit that referenced this pull request Sep 26, 2025
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants