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

For #27975: Ignore current tab when forcing inactive #28526

Merged
merged 2 commits into from
Jan 18, 2023

Conversation

DreVla
Copy link
Contributor

@DreVla DreVla commented Jan 13, 2023

This feature is only available in debug and it is used by developers and qa to test inactive tabs without having to change device time or wait 15 days for a tab to become inactive! This specific crash was caused when a user forced the current tab to be inactive, which led to the tab at the same time being inactive but still updating its metadata when certain actions we're done (closing the tab, switching to another tab). Since the crash was caused by having the current tab set as inactive while the user was still able to see it, now we ignore the current tab if it is selected to be set as inactive.

inactive_tab_fix.mp4

Pull Request checklist

  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not
  • Accessibility: The code in this PR follows accessibility best practices or does not include any user facing features. In addition, it includes a screenshot of a successful accessibility scan to ensure no new defects are added to the product.

QA

  • QA Needed

To download an APK when reviewing a PR (after all CI tasks finished running):

  1. Click on Checks at the top of the PR page.
  2. Click on the firefoxci-taskcluster group on the left to expand all tasks.
  3. Click on the build-debug task.
  4. Click on View task in Taskcluster in the new DETAILS section.
  5. The APK links should be on the right side of the screen, named for each CPU architecture.

GitHub Automation

Fixes #27975

@DreVla DreVla requested review from a team as code owners January 13, 2023 10:34
@DreVla DreVla added the needs:review PRs that need to be reviewed label Jan 13, 2023
Copy link
Contributor

@t-p-white t-p-white left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this has stopped the crashing 🙂
Being able to select the current tab and 'make inactive' but not actually making it 'inactive' doesn't feel like the right UX - I wonder if we should also remove/disable the ability to make a current tab 'inactive' altogether?
Edit: Although given this is just for debug builds perhaps that's fine

@DreVla
Copy link
Contributor Author

DreVla commented Jan 16, 2023

Nice, this has stopped the crashing 🙂 Being able to select the current tab and 'make inactive' but not actually making it 'inactive' doesn't feel like the right UX - I wonder if we should also remove/disable the ability to make a current tab 'inactive' altogether? Edit: Although given this is just for debug builds perhaps that's fine

We cannot really disable the ability to make a current tab 'inactive' since we do not know what the user wants to do when selecting the current tab in the tabs tray (maybe he wants to delete it or add it to a collection). I would say that considering this is just a debug feature, there is no need for further complications in the code.

@t-p-white
Copy link
Contributor

I would say that considering this is just a debug feature, there is no need for further complications in the code.

Understood. Code changes lgtm 👍

@DreVla DreVla added pr:approved PR that has been approved and removed needs:review PRs that need to be reviewed labels Jan 16, 2023
dispatch(DebugAction.UpdateCreatedAtAction(tab.id, daysSince))
val currentTabId = browserStore.state.selectedTabId
tabs
.filterNot { it.id == currentTabId }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Question: Should we add tests for it?

💡 Suggestion: Maybe we can add checks that it should only work on debugging mode and does nothing in other modes, not for this PR.

Copy link
Contributor Author

@DreVla DreVla Jan 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of adding tests but considering it is a feature used only for debugging, I didn't really see them necessary. Not sure if the suggestion is for the tests or for the feature. The check for the force inactive feature is implemented here: https://searchfox.org/mozilla-mobile/source/fenix/app/src/main/java/org/mozilla/fenix/tabstray/browser/SelectionMenu.kt#48

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point, although seeing that it did break, and you fixed it here, even for debugging adding the tests would avoid this from happening in the future, i leave it to your better judgement :)
Suggestion was for the feature, the check is somewhere else and from reading the comments it seemed like action can be used by mistake, adding a check there would prevent that. Again, not essential for this PR, but might prevent this super user feature from leaking into the release ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kudos to @Mugurell for helping, three new tests have been added which would ensure future stability for this feature.

Since the crash was caused by having the current tab set as inactive
while the user was still able to see it, now we ignore the current
tab if it is selected to be set as inactive.
@DreVla DreVla added the pr:needs-landing PRs that are ready to land [Will be merged by Mergify] label Jan 18, 2023
@mergify mergify bot merged commit e0d7480 into mozilla-mobile:main Jan 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr:approved PR that has been approved pr:needs-landing PRs that are ready to land [Will be merged by Mergify]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: The application crashes after deleting the last inactive tab displayed in the list
3 participants