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

Make scroll tracking configurable with a cap #284

Merged
merged 3 commits into from
Jun 11, 2019
Merged

Conversation

imurchie
Copy link
Contributor

Add trackScrollEvents cap, to configure the tracking of scroll movement. This improves performance of touch actions significantly:

Using a simple touch action:

const action = new wd.TouchAction();
action.press({x: 100, y: 100})
  .wait(100)
  .release();
await driver.performTouchAction(action);
  • trackScrollEvents set to true, averages 1710ms
  • trackScrollEvents set to false, averages 194ms

This could be changed to a setting if it is found to be necessary to switch between configurations mid-session.

Copy link
Member

@jlipps jlipps left a comment

Choose a reason for hiding this comment

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

looks good, couple small things

if (session.hasCapability(TRACK_SCROLL_EVENT_CAP)) {
try {
trackScrollEvents = (Boolean) session.getCapability(TRACK_SCROLL_EVENT_CAP);
Logger.error("Capability '" + TRACK_SCROLL_EVENT_CAP + "': " + trackScrollEvents);
Copy link
Member

Choose a reason for hiding this comment

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

is this meant to be an error log?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, no. That was just all that would show up in my logs without fiddling. I'll fix.

setResult(doTouchUp(x, y));
}
});
} else {
Copy link
Member

Choose a reason for hiding this comment

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

spacing seems off in this block

Copy link
Member

@jlipps jlipps left a comment

Choose a reason for hiding this comment

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

LGTM. i do still worry about breaking any existing use cases, so would prefer for this cap to default to true on the appium side, maybe with a deprecation notice for people not including the cap that the behavior will change?

@imurchie
Copy link
Contributor Author

That is the plan. In appium-uiautomator2-driver the cap will default to true.

Logger.debug("Capability '" + TRACK_SCROLL_EVENT_CAP + "': " + trackScrollEvents);
} catch (Exception e) {
Logger.error("Could not set '" + TRACK_SCROLL_EVENT_CAP + "' from capability: ", e);
trackScrollEvents = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

this is redundant

try {
trackScrollEvents = (Boolean) session.getCapability(TRACK_SCROLL_EVENT_CAP);
Logger.debug("Capability '" + TRACK_SCROLL_EVENT_CAP + "': " + trackScrollEvents);
} catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is getCapability supposed to throw an exception?

Boolean trackScrollEvents = true;
if (session.hasCapability(TRACK_SCROLL_EVENT_CAP)) {
try {
trackScrollEvents = (Boolean) session.getCapability(TRACK_SCROLL_EVENT_CAP);
Copy link
Contributor

Choose a reason for hiding this comment

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

how about using String.format?

Copy link
Contributor

Choose a reason for hiding this comment

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

same below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I personally think the else ought to be there when it is, logically, an else, even if the return makes it technically "redundant".

setResult(doTouchDown(x, y));
}
});
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

else is redundant

Copy link
Contributor

Choose a reason for hiding this comment

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

same below

@@ -32,6 +36,7 @@
private static final String METHOD_TOUCH_DOWN = "touchDown";
private static final String METHOD_TOUCH_UP = "touchUp";
private static final String METHOD_TOUCH_MOVE = "touchMove";
private static final String TRACK_SCROLL_EVENT_CAP = "trackScrollEvents";
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather make it an appium setting

@imurchie imurchie merged commit 4deab30 into master Jun 11, 2019
@imurchie imurchie deleted the isaac-touch-actions branch June 11, 2019 11:38
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.

3 participants