Skip to content
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

Bugfix FXIOS-10756 App hangs while opening Tab Tray when there are many tabs open #23474

Merged
merged 7 commits into from
Dec 10, 2024

Conversation

FilippoZazzeroni
Copy link
Collaborator

@FilippoZazzeroni FilippoZazzeroni commented Nov 29, 2024

📜 Tickets

Jira ticket
Github issue

💡 Description

Bug fix App hang while opening the tab tray that is mainly caused by the TabTrayDisplayView.newState being called many times. Optimize scrollToTab method to wait for the collection view layout to finish, instead of forcing layout.
Bug fix swipe gesture to delete tab flashing back to normal position after the tab was dismissed.

Here is the link of the currently tracked app hangs Spreadsheet

📝 Checklist

You have to check all boxes before merging

  • Filled in the above information (tickets numbers and description of your work)
  • Updated the PR name to follow our PR naming guidelines
  • Wrote unit tests and/or ensured the tests suite is passing
  • When working on UI, I checked and implemented accessibility (minimum Dynamic Text and VoiceOver)
  • If needed, I updated documentation / comments for complex code and public methods
  • If needed, added a backport comment (example @Mergifyio backport release/v120)

@FilippoZazzeroni FilippoZazzeroni requested a review from a team as a code owner November 29, 2024 14:04
@mobiletest-ci-bot
Copy link

mobiletest-ci-bot commented Nov 29, 2024

Messages
📖 Project coverage: 33.1%
📖 Edited 5 files
📖 Created 0 files

Client.app: Coverage: 31.73

File Coverage
TabDisplayPanelViewController.swift 72.41%
TabDisplayView.swift 40.09% ⚠️
SwipeAnimator.swift 15.15% ⚠️
TabTrayViewController.swift 57.52%
TabCell.swift 71.01%

Generated by 🚫 Danger Swift against ec62f29

Copy link
Contributor

mergify bot commented Nov 29, 2024

This pull request has conflicts when rebasing. Could you fix it @FilippoZazzeroni? 🙏

@FilippoZazzeroni
Copy link
Collaborator Author

FilippoZazzeroni commented Nov 29, 2024

@mergify backport release/v134

Copy link
Contributor

mergify bot commented Nov 29, 2024

backport release/v134

✅ Backports have been created

@@ -291,15 +291,19 @@ class TabTrayViewController: UIViewController,
}

func newState(state: TabTrayState) {
tabTrayState = state
updateTabCountImage(count: state.normalTabsCount)
defer {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to defer the state?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes true we can avoid it. I added it in case in future we want to end the newState method on some if branch, so we don't forget to apply the state, since with this implementation it must be set as last method operation.

if state.shouldDismiss {
  delegate.didFinish()
  // having defer would be nice here so we don't forget applying the state
  return
}

Copy link
Contributor

Choose a reason for hiding this comment

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

so, I'm confused here. We're not doing a check if the states are the same or not? what does defer get us vs setting tabTrayState = state at the beginning, and then updating, given that we're just basically update off state here??

Copy link
Collaborator Author

@FilippoZazzeroni FilippoZazzeroni Dec 4, 2024

Choose a reason for hiding this comment

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

Setting the state as first thing invalidates the checks because then tabTrayState will be always equal to state. Yes here the only state comparison is done on updateTabCountImage but yes you are right @adudenamedruby. i didn't implement the guard at the top cause i wasn't sure about any side effects it could cause. But i think that is the best idea

@lmarceau lmarceau changed the title Bugfix FXIOS App hangs while opening Tab Tray when there are many tabs open Bugfix FXIOS-10756 App hangs while opening Tab Tray when there are many tabs open Dec 2, 2024
@@ -162,9 +161,11 @@ class TabDisplayPanelViewController: UIViewController,
}

func newState(state: TabsPanelState) {
if state != tabsState {
Copy link
Contributor

Choose a reason for hiding this comment

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

would this be cleaner if it was a guard? so, guard tabsState != state else { return } and do the stuff only then? Or does the shouldShowEmptyView need to get called every time?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes i agree i'd be much more cleaner. The thing also for the other states i don't know if comparing the state and applying changes for different state could cause any side effects.
I believe it should be safe to do the comparison at the top since the state should be Equatable what do you think ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean, if we're comparing at the top of newState we should be fine, I think, because it's only doing this particular state. And yeah, everything should be Equatable state wise, so we should be safe.

But maybe I didn't understand the question. What do you mean by "also for the other states i don't know if comparing the state and applying changes for different state could cause any side effects"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry Rou i wasn't clear, i was referring to the other comment you wrote. So i'll go also for the TabTrayViewController.newState to have top comparison for the states

@@ -291,15 +291,19 @@ class TabTrayViewController: UIViewController,
}

func newState(state: TabTrayState) {
tabTrayState = state
updateTabCountImage(count: state.normalTabsCount)
defer {
Copy link
Contributor

Choose a reason for hiding this comment

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

so, I'm confused here. We're not doing a check if the states are the same or not? what does defer get us vs setting tabTrayState = state at the beginning, and then updating, given that we're just basically update off state here??

@FilippoZazzeroni
Copy link
Collaborator Author

@dataports i've merged main. You can test on new Xcode version if u want

@FilippoZazzeroni FilippoZazzeroni merged commit 2d5125e into main Dec 10, 2024
10 checks passed
@FilippoZazzeroni FilippoZazzeroni deleted the zazz/bugfix-tab-tray-opening-hangs branch December 10, 2024 11:51
mergify bot pushed a commit that referenced this pull request Dec 10, 2024
…ny tabs open (#23474)

* Little optimization on tab tray when updating counter image

* Optimize TabDisplayPanel newState to avoid unnecessary view reload, Fix Swipe to close tab cell causing a blink when the animation is about to close

* Refactor TabDisplayView to pipe collection view scroll after layout

* Refactor as per code review

* Refactor state to use tabState

---------

Co-authored-by: Filippo <[email protected]>
(cherry picked from commit 2d5125e)
FilippoZazzeroni added a commit that referenced this pull request Dec 10, 2024
…ny tabs open (backport #23474) (#23657)

* Optimize TabDisplayPanel newState to avoid unnecessary view reload, Fix Swipe to close tab cell causing a blink when the animation is about to close

* Refactor TabDisplayView to pipe collection view scroll after layout

* Refactor state to use tabState

---------

Co-authored-by: Filippo <[email protected]>
(cherry picked from commit 2d5125e)

Co-authored-by: FilippoZazzeroni <[email protected]>
@dataports
Copy link
Contributor

@dataports i've merged main. You can test on new Xcode version if u want

I'm late, but I just did a quick test and everything looks good 👍 thanks!

isabelrios pushed a commit that referenced this pull request Dec 11, 2024
…ny tabs open (backport #23474) (#23657)

* Optimize TabDisplayPanel newState to avoid unnecessary view reload, Fix Swipe to close tab cell causing a blink when the animation is about to close

* Refactor TabDisplayView to pipe collection view scroll after layout

* Refactor state to use tabState

---------

Co-authored-by: Filippo <[email protected]>
(cherry picked from commit 2d5125e)

Co-authored-by: FilippoZazzeroni <[email protected]>
@FilippoZazzeroni
Copy link
Collaborator Author

Ok thanks so much @dataports

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

Successfully merging this pull request may close these issues.

5 participants