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

Bug with displaying PopupContentViewController #24

Closed
balabon7 opened this issue Feb 1, 2023 · 23 comments
Closed

Bug with displaying PopupContentViewController #24

balabon7 opened this issue Feb 1, 2023 · 23 comments

Comments

@balabon7
Copy link

balabon7 commented Feb 1, 2023

Hello 👋
I have a bug displaying PopupContentViewController.

When I try to make a short gesture to pull up from the bottom of the PBPopupBar, sometimes there is a bug: where the PopupContentViewController is not displayed, but the system thinks that it is currently open.

On the screen I see a viewcontroller with PBPopupBar, but not a single button or cell is called.

And if PopupContentViewController has buttons, then they work (call their methods)

It is not always possible to cause a mistake, but if they try to make a lot of short swipe in the bar at some moment, all the elements on the current screen will stop responding (and, as I said, the PopUPContentViewController elements will begin to react)

This bug can only be removed when to roll up the application and expand.

Below I have added a screen recording video (to GoogleDrive) of how it is possible to play back:
https://drive.google.com/drive/folders/1u54fwfbhji9g0EDgndVxXS4zkAGZ6RO8?usp=sharing

Could you try to intervene this bug at home? (If it doesn’t work out, then I can provide logs)

@iDevelopper
Copy link
Owner

Hello,

I guess it's a conflict between the two gesture recognizers:

@objc public var popupTapGestureRecognizer: UITapGestureRecognizer!

@objc public var popupBarPanGestureRecognizer: UIPanGestureRecognizer!

As they are public, can you try to implement your own delegates on them and play with?

https://developer.apple.com/documentation/uikit/touches_presses_and_gestures/coordinating_multiple_gesture_recognizers/preferring_one_gesture_over_another

@balabon7
Copy link
Author

balabon7 commented Feb 3, 2023

Sure. 👍 I have not worked with gestures yet, but it will be interesting.
Thanks for the tip, I'll post back as soon as I get the results.

@iDevelopper
Copy link
Owner

Can you try 3.6.8? I tried some updates.

@balabon7
Copy link
Author

balabon7 commented Feb 9, 2023

Hi 👋 I checked the update 3.6.8 and 3.6.9, but this error remained and is reproduced, as before.

But I saw, after the mistake played -> I went into the background (without unloading from memory) -> opened the application, then “pressing” and the gesture “pull up” in PopupBar stop working.
(in version 3.6.7 after returning to the forefront, they worked)
(Although the buttons in Popupbar and the rest of the controller work as before)

@balabon7
Copy link
Author

balabon7 commented Feb 9, 2023

Please tell me, did you reproduced this bug?

If not, I can give my test build, where this behavior is better reproduced than in your PBPopupSample
(practical from several attempts)

I also tried to resolve the conflict between two gestures, but to no avail 🙁

@iDevelopper
Copy link
Owner

Hello,

I no longer reproduce this bug with my example. Can you provide an example project that would allow me to reproduce this more easily?

Thanks,

@balabon7
Copy link
Author

balabon7 commented Feb 9, 2023

Of course, please check PBPopupSample in the last community updated library to 3.6.10
https://github.com/balabon7/PBPopupSample

@balabon7
Copy link
Author

balabon7 commented Feb 9, 2023

Also added 2 videos as on the latest version is reproduced
IMG_8360.MOV and IMG_8358.MOV
I have AirPlay button in PopupContentController. The video shows how Alert with AirPlay is displayed by pressing PopupBar

https://drive.google.com/drive/folders/1u54fwfbhji9g0EDgndVxXS4zkAGZ6RO8?usp=sharing

@iDevelopper
Copy link
Owner

I'm pretty sure now that it's not a gesture conflict. But maybe a conflict with the controls of your content view controller.

Can you test by disabling interactions with the content view controller during the presentation?

    func popupController(_ popupController: PBPopupController, shouldOpen popupContentViewController: UIViewController) -> Bool {
        if let popupContent = popupContentViewController as? PopupContentViewController {
            popupContent.view.isUserInteractionEnabled = false
            return true
        }
        return false
    }
    func popupController(_ popupController: PBPopupController, didOpen popupContentViewController: UIViewController) {
        if let popupContent = popupContentViewController as? PopupContentViewController {
            popupContent.view.isUserInteractionEnabled = true
        }
    }

@balabon7
Copy link
Author

This bug still occurs, but its behavior has now changed

In version 3.6.10, after I reproduced the bug again, I still cannot gesture and click on the PBPopupBar and the buttons it contains.


But now when clicking on the PBPopupBar, I don't get access to the buttons that are in the PopupContentViewController and located in the same place on the View.

Previously tapping on PBPopupBar I could call a method from a button in PopupContentViewController.
For example, the AirPlay button.

And another important thing to do, which was before but I did not mention it, is that the progressView that is in the PBPopupBar stops the progress. (But self-playing audio continues)

If I bring the application to the background and bring it back to the front,
 then the buttons in the PBPopupBar will become clickable again, and the progressView in the PBPopupBar will correctly display the progress. But I won't be able to open PopupContentViewController with a tap or a "pull up" gesture.



I also checked version 3.6.7

The behavior of the bug is the same as in version 3.6.10, but if I minimize the application to the background and bring it to the foreground, I can open the PopupContentViewController with a tap or a "pull up" gesture, unlike version 3.6.10


Also added 2 videos «version3.6.7.MOV» and «version3.6.10.MOV» where the behavior is reproduced
https://drive.google.com/drive/folders/1u54fwfbhji9g0EDgndVxXS4zkAGZ6RO8?usp=sharing

@balabon7
Copy link
Author

Another interesting detail:
I find it easier to reproduce the bug when I add values ​​to the


func popupController(_ popupController: PBPopupController, shouldOpen popupContentViewController: UIViewController) -> Bool




 popupContent.albumArtImage = self.containerVC.popupBar.image
popupContent.trackNameLabel.text = self.containerVC.popupBar.title
popupContent.artistNameLabel.text = self.containerVC.popupBar.subtitle

If I do not fill in these values, then the bug is also reproduced but with more attempts (Suddenly this information will be useful)

@iDevelopper
Copy link
Owner

After some investigation, I noticed that in this case the pan gesture recognizer does not enters the UIGestureRecognizer.State.changed state.
After the UIGestureRecognizer.State.began state the pan gesture recognizer enters directly the UIGestureRecognizer.State.ended state, which causes this issue !
I think it's an Apple bug, as after the began state, the gesture should enter in the changed state:
https://developer.apple.com/documentation/uikit/touches_presses_and_gestures/handling_uikit_gestures/handling_pan_gestures
I need to find a workaround.

@balabon7
Copy link
Author

Maybe you should ask a question in Code-level support? dts@apple.com



Perhaps support will suggest a better solution (especially if the bug is on their side)

If you have free TSI, we can ask a question
.

Or I can ask. I have available TSIs.

@balabon7
Copy link
Author

balabon7 commented Feb 14, 2023

I don't know much about this library LNPopupController, but you may have explored it more.
https://github.com/LeoNatan/LNPopupController

Does LNPopupController use the same gesture interaction principle?

Or do you not like this implementation of the "pull up" gesture?

(So far I have no other ideas how we can implement a workaround ☹️)

@iDevelopper
Copy link
Owner

I know the workaround.

LNPopupController is a very good framework, but it was designed to animate a view, not to present a view controller. PBPopupController uses UIPresentationController coupled with an interactive animator (UIPercentDrivenInteractiveTransition) and an animator (UIViewPropertyAnimator). UIKit requests the start of the animation when necessary. When the pan gesture recognizer enters directly the ended state, it is too late.

You can have a look here:
https://developer.apple.com/library/archive/featuredarticles/ViewControllerPGforiPhoneOS/CustomizingtheTransitionAnimations.html

LN also uses UIPanGestureRecognizer but this bug has no impact on the flow of the animation since it is programmed manually when the pan enters the changed state.

Also you can see the differences between the features of LN and PB here:
LeoNatan/LNPopupController#348

@balabon7
Copy link
Author

Wow, thanks for the detailed description.
 👍
I've read the entire article on setting up a transition animation, and I've got at least a basic understanding of how it works.
I didn’t think that LN would present view, not VC
And «iOS animation card» came from ViewController in PB

@iDevelopper
Copy link
Owner

And «iOS animation card» came from ViewController in PB

In PB I had called it "deck", since iOS 13 Apple called it pageSheet.

@iDevelopper
Copy link
Owner

Can you check 3.6.11?

@balabon7
Copy link
Author

balabon7 commented Feb 18, 2023

Hello. I checked 3.6.11

When I make a gesture "sharp swipe up" (conditionally call the movement that causes bug), the PopupContentViewController is now instantly displayed (There is no opening animation in this case)

And the bug itself (in the old form is no longer called), and this solution seems to work.
 👍

But I wanted to clarify:
Can we add an opening animation?

If we don't control the gesture "sharp swipe up" when it's called (I mean it happens instantly), then assign a tap on the PBPopupBar in this case?
(So ​​that the PopupContentViewController would open like by clicking on the PBPopupBar and cause the animation)

If it possible 🤔

I attached the video fixbug.mp4 how it happens to me

https://drive.google.com/drive/folders/1u54fwfbhji9g0EDgndVxXS4zkAGZ6RO8?usp=sharing

@balabon7
Copy link
Author

balabon7 commented Feb 18, 2023

When I do "sharp swipe up" gesture , it creates the visual effect ( of the PopupBar ) artifacts in the PopupContentViewController for half a second.

I found a simple solution for this:

Add animator.fractionComplete = self.progress to self.shouldComplete (func startInteractiveTransition)

 This removes the visual effect.

override func startInteractiveTransition(_ transitionContext: UIViewControllerContextTransitioning)
{
super.startInteractiveTransition(transitionContext)
self.animator = self.presentationController.interruptibleAnimator(using: transitionContext) as? UIViewPropertyAnimator
if self.shouldComplete {
PBLog("shouldComplete", error: true)
self.availableHeight = self.popupContainerViewAvailableHeight()
self.continuePresentationAnimation()

// removes artifacts from PopupContentVC left over from PopupBar
animator.fractionComplete = self.progress
return
}
self.availableHeight = self.popupContainerViewAvailableHeight()
self.panDirection = .right
self.progress = 0.0
animator.fractionComplete = self.progress
self.update(self.progress)
}

Знімок екрана 2023-02-18 о 11 46 34

Знімок екрана 2023-02-18 о 11 46 43

@iDevelopper
Copy link
Owner

Hello,
Oh sorry!
I made a mistake, I did not code the same thing in my update as in my tests with your application.
In continuePresentationAnimation(), it is:

animator.continueAnimation(withTimingParameters: UICubicTimingParameters(animationCurve: .linear), durationFactor: 0.5)

instead of:

animator.continueAnimation(withTimingParameters: nil, durationFactor: 1.0)

You can test and I will update very soon.

@iDevelopper
Copy link
Owner

Fixed by 3.6.13

@balabon7
Copy link
Author

Awesome. I tested the new build 3.6.13. Everything works fine, and most importantly, there is no bug.
Thank you for improving the library 😊

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

No branches or pull requests

2 participants