Page MenuHomePhabricator

Implement Tap to show for lazy loaded images without MutationObserver - Scrolling on a Kai OS mobile device can be slow on articles with lazy loading
Closed, DuplicatePublic

Description

NOTE: In T246838 we will rewrite lazy loading to use MutationObserver. That will be done first.

With T246838 browsers that do not support MutationObserver will load all images on page load. This is not ideal and we'd like to replace it with a click to load pattern. This will mean images will get loaded only owhen the image is clicked/tapped by the reader.

Screen Shot 2020-03-25 at 10.17.13 AM.png (1×1 px, 355 KB)

@alexhollender feel free to suggest better solutions.

Analysis/background by Peter

I've been testing our new Kai OS application but I also tested our current mobile web on Kai OS device. As I said before, it looks good, a couple small fixes and would almost be perfect.

The main problem is scrolling, the frames per second can be really slow. On a Kai OS device you don't swipe instead you press a key to scroll. I've recorded two example so you can see what looks like:

This is start page, it scrolls as other web sites do, it looks good!

But for articles with lazy loaded images it is really slow (I keep pressing the button to scroll as fast as possible):

Kai OS runs on a modified version of Firefox 48, so you can connect to it with an old Firefox WebIDE. Looking at time spent it looks like this:

Screen Shot 2020-03-03 at 8.31.05 AM.png (1×1 px, 493 KB)

There's a lot of time spent if checking elements is in the viewport. @Jdlrobson do you have an idea of how we could improve it? Is it triggered now for every scroll, so every key press will generate a check?

Developer notes

Once https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/MobileFrontend/+/587893 is done this should be rather straight forward - you can add a click handler for the events. The question is what feedback we should give to the user.

Event Timeline

Just wanted add after our discussion about lazy loading yesterday, the long term solution as @Gilles proposed should be to load on click for devices that don't support our lazy loading. I'll check if we have a task for long term how to handle lazy loading, if not I'll create one.

Should be fixed by T246838 but we may want to split out the click to tap behaviour into a separate task so will keep open just in case.

Jdlrobson renamed this task from Scrolling on a Kai OS mobile device can be slow on articles with lazy loading to Implement Tap to show for lazy loaded images without MutationObserver - Scrolling on a Kai OS mobile device can be slow on articles with lazy loading.Mar 25 2020, 4:58 PM
Jdlrobson updated the task description. (Show Details)

@alexhollender I need some help with the UX for this one.

Change 587893 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/extensions/MobileFrontend@master] Lazy loading with IntersectionObserver

https://gerrit.wikimedia.org/r/587893

Chatted with Alex today and he said this will be fine:

Screen Shot 2020-04-10 at 11.30.30 AM.png (716×724 px, 69 KB)

We've decided to do this as part of T246838. The tap to show image behaviour is pretty straightforward that it doesn't need its own task.

Change 587893 merged by jenkins-bot:
[mediawiki/extensions/MobileFrontend@master] Lazy loading with IntersectionObserver

https://gerrit.wikimedia.org/r/587893