Skip to content

Conversation

@mkevins
Copy link
Contributor

@mkevins mkevins commented Jul 1, 2022

Fixes #16847

Description

This PR re-enables the larger screenshots disabled as a work-around in #16747. Formerly, the scale parameter was not being passed (or defaulted to 1).

Since this parameter is needed to achieve properly sized screenshots for higher screen densities, this PR passes this value based on the device's screen density. Since the dimensions are already scaled by this value (by default when retrieving the dimension resource in Android), this PR manually. But, since the backend also uses the scale parameter to calculate the correct dimensions, to avoid doing this transformation twice, we divide by this value to calculate the correct dimensions for the request parameters. This is needed so that we can maintain API compatibility with older client versions.

Without this workaround, the scale will be applied twice, resulting in larger images than necessary (and longer download times, more data usage, and decreased performance).

This PR also fetches the screenshots for the theme picker using the dimensions from the "recommended" sizes (rather than "category" sizes). Other changes this PR relies on are on the API side (D83271-code).

Testing steps

Pre-conditions:

  • Device should be connected to a WPCOM sandbox (The back-end changes have been deployed).
  • The patch should be applied to the sandbox from D83271-code
  1. Navigate to the site creation flow
  2. Choose an Intent (e.g. "Food")
  3. Expect the recommended for you screenshots to be larger
  4. Expect the screenshots to be loaded with proper display resolution (i.e. not pixelated)
    • It can be helpful to inspect traffic (e.g. in Android Studio network inspector) to ensure that properly sized screenshots are requested.
    • Inspecting traffic can also help confirm that the returned screenshots are the correct size (limited to 1200 width).

Page picker

The page picker should not be affected by these changes (though backend changes in the API may result in changes to the fetched screenshot URLs)

Regression Notes

  1. Potential unintended areas of impact
    Page picker

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    Manual tests

  3. What automated tests I added (or what prevented me from doing so)
    Establishing the required testing apparatus for this would be out of scope for this task.

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

mkevins added 4 commits June 30, 2022 14:24
We use the `ThumbDimensionProvider` for displaying as well as fetching
preview screenshots with the correct dimensions. The values are
automatically scaled based on screen density on the client side, but for
legacy reasons, the API endpoint *also* scales the dimensions, resulting
in the scale being applied twice. To avoid this, we divide by the scale
factor when computing the dimension parameters to fetch the designs.

This can be revisited in the future if we change or version the REST
endpoint to remove the middleware scaling behavior.
@peril-wordpress-mobile
Copy link

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jul 1, 2022

You can test the WordPress changes on this Pull Request by downloading an installable build (wordpress-installable-build-pr16848-8cc4806.apk), or scanning this QR code:

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jul 1, 2022

You can test the Jetpack changes on this Pull Request by downloading an installable build (jetpack-installable-build-pr16848-8cc4806.apk), or scanning this QR code:

@mkevins mkevins requested a review from antonis July 1, 2022 07:52
@mkevins mkevins added this to the 20.5 milestone Aug 1, 2022
@mkevins mkevins marked this pull request as ready for review August 1, 2022 21:52
@mkevins mkevins requested a review from ovitrif August 1, 2022 21:52
Copy link
Contributor

@antonis antonis left a comment

Choose a reason for hiding this comment

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

Great work @mkevins 👍
I've tested the implementation on a Pixel 5 (Android 12) and on a Pixel C tablet emulator. Everything worked as expected for me. The code changes also look good and the explanatory comments should be helpful in the future 🎉
Thank you for fixing this 🙇

@antonis antonis merged commit 670bce1 into trunk Aug 2, 2022
@antonis antonis deleted the try/re-enable-large-recommended-theme-screenshots branch August 2, 2022 12:47
@mkevins
Copy link
Contributor Author

mkevins commented Aug 2, 2022

Thank you for reviewing and testing!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Re-enable large recommended theme previews

4 participants