-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Replace design screenshots with mShots in New Onboarding #43428
Replace design screenshots with mShots in New Onboarding #43428
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: App Entrypoints (~241 bytes added 📈 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
Yeah, Reynolds (and perhaps other designs?) need a bit extra CSS help somehow: wp-calypso/bin/generate-gutenboarding-design-thumbnails.js Lines 59 to 64 in 1227e50
|
Thanks @simison that CSS does the trick. I've worked up a diff for adding the override to the |
541ab92
to
4116f52
Compare
vph: 3072, | ||
w: 700, | ||
h: 1800, | ||
// requeue: true, // Uncomment this line to force the screenshots to be regenerated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also add cache-busting timestamp coming from templates API?
const mshotsRequest = addQueryArgs( mshotsUrl + encodeURIComponent( previewUrl ), { | ||
vpw: 1200, | ||
vph: 3072, | ||
w: 700, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be better to have 700
in constant so that nobody misses updating it between previewUrl
and mshotsRequest
?
Edit: Oh, I just realized this was height and width, not height and height 😁
setResolvedUrl( mShotsEndpointUrl ); | ||
} | ||
|
||
if ( response.status === 307 ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if status
is something else (e.g. an error 500), we could just keep looping otherwise for a while and then give up by disabling the preview thumbnail?
Not very high priority or blocking this PR though.
client/landing/gutenboarding/onboarding-block/design-selector/index.tsx
Outdated
Show resolved
Hide resolved
4116f52
to
f392fd8
Compare
I'm wrapping up for the day and will be AFK until next week, when I'm then on gardening duty, so mightn't have time to work on this one for a couple of weeks. Feel free to pick this up, if anyone would like to! Here are some notes / things to investigate from where I've gotten up to. While working on it I found it easiest to add Some to dos:
Just some thoughts, feel free to change / go in a different direction if you happen to pick up this PR. Even though there's a fair bit to getting this working smoothly, the vertical screenshots are looking pretty good, and I'm happy so far with how the loading / onload state is looking: |
We could add a custom header in response at mshots? |
|
||
React.useEffect( () => { | ||
async function fetchMshots() { | ||
const response = await window.fetch( mShotsEndpointUrl, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative, just for your consideration:
const img = new Image();
img.addEventListener('load', (event) => {
// event
}, false);
img.src = mShotsEndpointUrl;
Might help with cors stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's a nice idea! Unfortunately, I think we might still need to use the fetch approach if we want to hide the fallback /default
route that renders the default loading gif, by handling the 307 redirect case.
It just occurred to me that I haven't looked into the link prefetch that we're doing in prefetchDesignThumbs
— my hunch is that we need to add the crossorigin
attribute, and this might explain why the CORS requests appear to be failing some of the time, but not when I directly reload the Design step. Just a hunch, though! I'll take a quick look early next week and see if it fixes it, if no-one beats me to it!
Yeah, it's looking great overall but there are a few little oddities. Different things in different previews, so I think in addition to the css fixes we'll want to pass size/viewport parameters through from |
@simison @andrewserong : I was looking at Rockfield, and the viewport_height param on the template demo endpoint helps, but the images still end up the wrong size and looking pretty bad. I had a play with mshots, and I think this might be a better solution than special-casing the css, but I wanted to make sure I wasn't just geeking out. Do you think this approach is worth completing? : Automattic/mShots#19 |
@deBhal nice, thanks for exploring this! It'd be worth commenting about it on p3topS-Ia-p2 as well, since there's some earlier related discussion there. Personally I think that's a good direction to go down, considering that we'd like to be able to support a wider range of designs than we currently have, and who knows what other kinds of workarounds we might need to add for special-casing CSS in the future. If mShots can behave a little bit more like a "real" 16:9 browser that's scrolled down the page, then it might save us time further down the track to handle it in mShots. That said, I have very little knowledge of how mShots works, and it's used in a lot of other places, too, so we'd need to be careful that it doesn't conflict with how any other services are using it. The other param I kinda wish we could support is a custom |
@deBhal Could you update the description and test plan so folks can start testing? Thanks! |
eecba45
to
8b044f9
Compare
client/landing/gutenboarding/onboarding-block/acquire-intent/index.tsx
Outdated
Show resolved
Hide resolved
client/landing/gutenboarding/onboarding-block/design-selector/index.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't looked into the e2e failures, but we discussed in chat that they're not related to this PR, so assuming that's the case, I say .
There are a number of issues with this approach, but this PR is a clever & working solution to some of them.
My biggest concern is the 10 second delay between page load and starting the request that actually succeeds. It's hard to see mShots being a viable approach if it's going to be common for users to be waiting that long on rarer locales.
Again, though, this code is working impressively well, good job!
…design step in Gutenboarding
…fetchDesignThumbs
2279086
to
900d933
Compare
Changes proposed in this Pull Request
template/demo
endpointMshotsImage
component that can deal with hiding the mShots default loading gif, and continue to request the image until it loads the final screenshot. The user should only see a pulsing rectangle until the image finally loadsOutstanding issues and todos
Screenshot
Testing instructions
?flags=gutenboarding/mshot-preview
or build locally and runcalypso.localhost:3000/new/ko?flags=gutenboarding/mshot-preview
./new/ko?flags=gutenboarding/mshot-preview
or/new/de?flags=gutenboarding/mshot-preview
Related to #37665
Fixes #48867