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

PageBoyViewController freeze when push a new VC during auto-scrolling transition #166

Closed
nsmag opened this issue Jul 6, 2018 · 17 comments
Closed
Labels

Comments

@nsmag
Copy link

nsmag commented Jul 6, 2018

If push a VC when the auto-scroll transition start, when back to the PageBoyVC, it will not respond to scroll/tap and autoScroller stop working too.

This is only happen with autoScroller. It's working fine with user-scroll

@corbinhudson
Copy link

I have the same issue except I am not using auto scroll (direct). I load a 3 paged table view, and when the user clicks on tab if it is empty (for first time) it pushes to new VC. When user hits back the view is frozen and will not respond

@nsmag
Copy link
Author

nsmag commented Jul 18, 2018

I'm not sure if this happen because the completion block of scrollToPage is not called when pushing a new VC during animation

...
                self.isScrollingAnimated = animated
                let direction = directionForPageScroll(to: page, index: rawIndex)
                
                let transitionCompletion: TransitionOperation.Completion = { (finished) in
                    if finished {
                        let isVertical = self.navigationOrientation == .vertical
                        let currentPosition = CGPoint(x: isVertical ? 0.0 : CGFloat(rawIndex),
                                                      y: isVertical ? CGFloat(rawIndex) : 0.0)
                        self.currentPosition = currentPosition
                        self.currentIndex = rawIndex
                        
                        // if not animated call position delegate update manually
                        if !animated {
                            self.delegate?.pageboyViewController(self,
                                                                 didScrollTo: currentPosition,
                                                                 direction: direction,
                                                                 animated: animated)
                        }
                    }
                    
                    self.autoScroller.didFinishScrollIfEnabled()
                    completion?(viewController, animated, finished)
                    self.isScrollingAnimated = false
                }
...

setting self.isScrollingAnimated to true will disable user interaction

@corbinhudson
Copy link

I am using Tabman in combination with Pageboy, I made no changes to my code except update pod and the error occurred. Reverted Pagepoy to 2.3 & Tabamn to 1.5.2 and now is working no problem. Will wait for fix

@msaps
Copy link
Member

msaps commented Jul 18, 2018

@corbinhudson @nsmag okay will check it out! Looks like it was probably a regression with updating the transition stuff in 2.4

@msaps
Copy link
Member

msaps commented Jul 18, 2018

@nsmag @corbinhudson could you try 2.5.3 and see if that fixes the issues you're having?

I managed to reproduce issues when pushing a new VC during an animated transition - which are now fixed as seen below:

interruption fix

@nsmag
Copy link
Author

nsmag commented Jul 19, 2018

@msaps looks like the issue still exists with 2.5.3.

I created a demo here

In the demo, the first VC is a Pageboy with 3 VCs (red, yellow, green)
then I use dispatch queue to push a new VC when pageboy starting transition, press back and the pageboy VC will freeze.

demo-pageboy-transition-issue

@msaps
Copy link
Member

msaps commented Jul 19, 2018

@nsmag okay thanks for that! Will check it out 👍

@msaps
Copy link
Member

msaps commented Jul 19, 2018

@nsmag just released 2.5.4 which should resolve the issue! Hopefully second time is the charm. 😄

The demo project really helped!

interruption-fix

@nsmag
Copy link
Author

nsmag commented Jul 19, 2018

@msaps It still freeze if pushing at the right moment
let's set timer in the demo to 1.9

DispatchQueue.main.asyncAfter(deadline: .now() + 1.9) {...

I updated the demo repo.

@msaps
Copy link
Member

msaps commented Jul 19, 2018

@nsmag are you using 2.5.4? The demo project works fine for me with the 1.9 delay on 2.5.4.

Demo with 2.5.4

@nsmag
Copy link
Author

nsmag commented Jul 19, 2018

@msaps Sorry I forgot to pod update. The demo works fine.

I'll test it on my project.

@nsmag
Copy link
Author

nsmag commented Jul 19, 2018

@msaps
If the PageboyVC is in table view, it'll freeze.
I'm not sure if I did anything wrong

I updated the demo repo:
the first VC is a UITableViewController with PageBoyViewController in it.

Or is there any workaround in this case?

@corbinhudson
Copy link

I tested in my project with updates, working now thanks!

@msaps
Copy link
Member

msaps commented Jul 19, 2018

@nsmag An additional tweak I want to make is to pause the auto scrolling when viewWillDisappear() is received and restarting on viewDidAppear - as currently the auto scrolling will continue when offscreen.

With your implementation in the UITableViewCell however, the PageboyViewController won't receive the correct lifecycle events as it is never added as a child view controller. This is probably why this issue is reproducible as it relies on viewWillAppear and other lifecycle events. I would recommend implementing this differently (perhaps the parent VC owns the child PageboyViewControllers and provides them to the cells rather than the cell owning it?)

@nsmag
Copy link
Author

nsmag commented Jul 19, 2018

@msaps I totally forgot about child VC. I'll try another test. thanks!

@nsmag
Copy link
Author

nsmag commented Jul 19, 2018

@msaps
2.5.4 fixed this issue

about pageboy in table view, it's my bad, I just forgot addChildViewController()
Thanks!

@nsmag nsmag closed this as completed Jul 19, 2018
@ahmedk92
Copy link
Contributor

ahmedk92 commented Aug 21, 2019

Freezes on iPhone 6s Plus iOS 12.3.1 with scrollToPage. Pageboy version: 3.3.0.

Edit: It's solved now. Here's what I thought was happening:

  • I had the PageboyViewController to be of a width proportional to its superview with a non-integer factor. This resulted in pages to rest on a non-integer horizontal offset (x). As I investigated, I found Pageboy to use such logic to determine if a scroll is in action.
  • Solution was just to make sure the PageboyViewController's width is integer.

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

No branches or pull requests

4 participants