Closed Bug 1673728 Opened 4 years ago Closed 4 years ago

Add machinery to synthesize PanGestureInput events on macOS

Categories

(Core :: Panning and Zooming, task)

task

Tracking

()

RESOLVED FIXED
84 Branch
Tracking Status
firefox84 --- fixed

People

(Reporter: kats, Assigned: kats)

References

Details

Attachments

(2 files, 1 obsolete file)

Attached patch WIP patch (obsolete) — Splinter Review

APZ tests that currently synthesize "native wheel" events go through this codepath on macOS. That generates a system scroll event which fails the hasPhaseInformation check and therefore results in creation of a ScrollWheelInput rather than a PanGestureInput. The ScrollWheelInput codepath is somewhat different to the PanGestureInput codepath (see the bodies of the case statements, as well as the different handling inside APZ code).

In real-world usage on mac laptops, the PanGestureInput codepath is the one that gets used, and in our testing, the ScrollWheelInput codepath is the one that gets used. It would be better if we could write tests for either codepath, or if not, default to having them go through the more-common PanGestureInput codepath.

I tried doing this today but was not successful. The minimal change that's needed is something like in the attached patch, but that fails tests. The problem with the attached patch is that all the PanGestureInputs generated have their type as PANGESTURE_PAN. The input queue will transmogrify the first of these into a PANGESTURE_START and send subsequent ones to the same APZC instance. So when running multiple tests in a row, the subsequent events get directed to APZCs that are already destroyed and so they get lost.

The solution to that problem may be to synthesize events with PANGESTURE_START (using a "1" instead of a "2" as the aNativeMessage) but when I tried that it seemed to unexpectedly trigger the page navigation swipe gesture. For some reason the generated events have a large delta in the x-direction even though we're definitely not requesting any such x-delta.

Actually since the x-delta thing happens even with the current ScrollWheelInput codepath maybe that's a separate problem to be tackled separately. Instead, I can suppress the swipe gesture navigation thing using prefs.

On second thought the x-delta problem seems like something that could cause other failures too, even if I suppress the swipe gesture navigation thing. So I'll try to dig into that more.

So apparently the problem is the delta values passed in here are doubles. And the function is expecting int32_t. But it's doing some objective-C stupidity and not doing a proper conversion, thereby putting mostly garbage into the generated scroll event. Explicitly casting those arguments makes things sane. Sigh.

Hopefully fixing this won't break existing tests... https://treeherder.mozilla.org/#/jobs?repo=try&group_state=expanded&revision=6c62d18ffb450a20ec71e753df572f1895b61268

Attachment #9184087 - Attachment is obsolete: true

Apparently objective-C doesn't do a great job when you give a vararg function
that takes int32_t arguments double values. I guess tests that use macOS
synthesized wheel inputs were basically only working by accident.

This causes the generated scroll events to be turned into PanGestureInput events
instead of ScrollWheelInput events. This exercises different codepaths that are
more representative of real-world behaviour on mac laptops. This patch also
allows a pref to flip the behaviour back to the old behaviour of triggering
ScrollWheelInputs, since in some cases we may want to test that behaviour
explicitly.

Depends on D95320

Pushed by kgupta@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/af6e2a613f7a
Don't put garbage in the synthesized scrollwheel event. r=tnikkel
https://hg.mozilla.org/integration/autoland/rev/5418b2ee8b24
Default to adding phase information to the synthesized scroll events on macOS. r=tnikkel
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 84 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: