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

Feature/inconsistent screenshot height #397

Merged
merged 8 commits into from
Oct 24, 2018

Conversation

Jakub-Izbicki
Copy link
Contributor

@Jakub-Izbicki Jakub-Izbicki commented Oct 16, 2018

Add algorithm to enable taking long screenshots without resolution-sleep-resolution workaround.

Description

This is a proposed solution no. 2 from issue #357. An algorithm that takes samples of page height in defined periods of time.
Adds new param to <screen/> called samplingPeriod, which defined waiting time between taking samples.
Please give suggestions if all proposed default values in algorithm are ok, and if some of them should be configurable or not:

  1. samplingPeriod - 100ms (configurable)
  2. Number of last n height samples to compare - 3 (not configurable)
  3. Max number of algorithm iterations = 15 (not configurable)

Please note, this pr is supposed to be merged after #387. There are several todos in code that indicate the tests should be changed to test proper page heights.

Motivation and Context

Fixed #357

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

I hereby agree to the terms of the AET Contributor License Agreement.

*/
public static <T> T waitForValue(Supplier<T> samplesSupplier, int samplingPeriod,
int sampleQueueSize, int maxSamplesThreshold) {
LinkedList<T> samplesQueue = new LinkedList<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you consider using org.apache.commons.collections.buffer.CircularFifoBuffer ? I think you can use it here to simplify your code :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great suggestion! I have updated the code.

@Jakub-Izbicki Jakub-Izbicki force-pushed the feature/inconsistent-screenshot-height branch 2 times, most recently from 3c32a98 to f096cfc Compare October 19, 2018 10:42
@Jakub-Izbicki Jakub-Izbicki force-pushed the feature/inconsistent-screenshot-height branch from f096cfc to 675de4c Compare October 19, 2018 10:45
@ghost
Copy link

ghost commented Oct 23, 2018

Tested, OK!

Copy link
Contributor

@tkaik tkaik left a comment

Choose a reason for hiding this comment

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

Good job! I think it's OK to only make the "samplingPeriod" a configurable parameter

.checkRange(height, 1, MAX_SIZE,
"Height should be greater than 0 and smaller than " + MAX_SIZE);
} else {
samplingPeriod = Optional.ofNullable(params.get(SAMPLING_PERIOD_PARAM))
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no limit for the samplingPeriod.
Just a question here: shouldn't that be limited somehow?
What will happen if user sets here e.g. 10000000 ms?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are correct, there should be a range for this param. I will set max at 10 seconds. Please give suggestion if the value seems reasonable.

@Jakub-Izbicki Jakub-Izbicki force-pushed the feature/inconsistent-screenshot-height branch from 9efdd9c to 16d944f Compare October 23, 2018 09:13
@tkaik tkaik merged commit f039c31 into master Oct 24, 2018
@tkaik tkaik deleted the feature/inconsistent-screenshot-height branch October 24, 2018 09:30
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.

Inconsistent screenshot height when height param in resolution modifier is omitted
5 participants