| Summary: | When mouse/trackpad click on WKWebView dismisses a UIKit menu, web gets touch down with no touch up, and no subsequent mouse events | ||||||
|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Kurt Revis <krevis> | ||||
| Component: | UI Events | Assignee: | Nobody <webkit-unassigned> | ||||
| Status: | NEW --- | ||||||
| Severity: | Normal | CC: | a_protyasha, karlcow, webkit-bug-importer, wenson_hsieh | ||||
| Priority: | P2 | Keywords: | BrowserCompat, InRadar | ||||
| Version: | Safari 16 | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Attachments: |
|
||||||
Also filed Apple Feedback FB12229344. You can also repro the bug with the web view on its own! Steps: 1. Build and run the project on iPad with trackpad 2. Move the pointer over text in the web view, 3. Two-finger click on the trackpad, showing the context menu 4. Click outside the menu, but on the web view, to dismiss the menu These symptoms are similar to https://bugs.webkit.org/show_bug.cgi?id=236390, although the repro steps are different. > This bug makes it very difficult to use modern pointer events in our web content. We would really like to use them over the old-style mousedown/mouseup events, since they present a unified interface for touches, pointing devices, and Apple Pencil, but it’s very hard to deal with a bug where it just stops working and there’s no way to fix it afterwards.
For the Web content, does it create an issue because the same code can't be used in an Android context? Or is it an issue very specific to the iPad context?
I'm not sure I understand the question. The difficulty is entirely on iPad devices, since that's the only place we see this bug. Other devices (e.g. Android, Chrome on macOS) will consistently send pointer events no matter what happens. So, only on iPad, I would need to implement and support two simultaneous paths to receive events: (1) through pointer events, (2) via traditional mouse events. Because (1) could silently stop working at any time, I'd need to somehow seamlessly cut over to (2) as soon as those events start appearing. But since mouse events don't support things like multitouch, it would be at best a fallback mechanism. And after that fallback, the only way to restore full functionality is to reload the web view, which is a terrible user experience. Kurt, Thanks for the additional details. This is helpful. Also see https://bugs.webkit.org/show_bug.cgi?id=236390 for a similar case, in pure web content, where pointerdown events stop working. |
Created attachment 466596 [details] Xcode project for an iPad app to demonstrate the bug We have a UIKit app containing a WKWebView, with buttons that show a UIKit menu above the web view. When we show a menu, then dismiss it by clicking with mouse/trackpad on the web view, the web view’s event handling is disrupted, making it unusable until the page is reloaded: - A pointerdown event with pointerType “touch” is sent, with no corresponding pointerup or pointercancel. - Subsequent clicks don’t send pointerdown or pointerup at all. Instead we get old-style mousedown and mouseup events. Steps: 1. Run attached project on iPad with a mouse or trackpad attached, or in the simulator. 2. Using any input method, press the “Menu” button to show a menu. 3. Using mouse or trackpad, click and release, outside the menu, on the web view. 4. Click again in the web view. Expected: - The web view prints “pointerdown mouse” and “pointerup mouse”, once for each click. Actual: - The first click makes the web view print “pointerdown touch”. There is no subsequent “pointerup” or “pointer cancel”. - The second click prints “Old-style mousedown! Should have seen a pointerdown instead” and “Old-style mouseup! Should have seen a pointerup instead”. - It remains in this state until you press the Reload button to reload the page. Notes: The bug happens on iPadOS 15, 16, and 17 developer beta 1. Both on device and in the simulator. The sample app demonstrates two different bugs — see the explanatory text when you run the app. This is “Bug #2”. In the test app, there is a native gesture recognizer above the web view, that does nothing but observe touches and log them to the console. It sees touches with type `.indirectPointer` as expected. When the bug is triggered, you’ll note that it gets a touch began, but *not* a touch ended or cancelled, and then reset. I’m guessing that WebKit’s `WKMouseGestureRecognizer` is not expecting that sequence, and somehow leaves the web content process in a weird state. This bug makes it very difficult to use modern pointer events in our web content. We would really like to use them over the old-style mousedown/mouseup events, since they present a unified interface for touches, pointing devices, and Apple Pencil, but it’s very hard to deal with a bug where it just stops working and there’s no way to fix it afterwards. It’s also difficult to work around, because UIKit doesn’t always provide a simple way to find out when the menu is shown and dismissed. If the menu is the overflow menu in a navigation bar, for instance, it doesn’t provide a way to observe the menu, and there isn’t a way to make a custom subclass of UIBarButtonItem for it (which could).