Page MenuHomePhabricator

Combine imageinfo requests on load
Closed, ResolvedPublic8 Estimated Story Points

Description

  1. Go to http://en.wikipedia.org/wiki/Barack_Obama as a logged-in user in Chrome
  2. Open the inspector, go to the network panel, click the filter icon and select "XHR"
  3. Click Edit beta
  4. Observe lots of POST /w/api.php requests, one for each image

We should combine these requests rather than doing a separate one for each image.

Event Timeline

Catrope raised the priority of this task from to Needs Triage.
Catrope updated the task description. (Show Details)
Catrope added a project: VisualEditor.
Catrope changed Security from none to None.
Catrope subscribed.
Jdforrester-WMF renamed this task from Combine imageinfo requests to Combine (or defer until needed?) imageinfo requests on load.Dec 12 2014, 1:28 AM

Change 180228 had a related patch set uploaded (by Alex Monk):
[WIP] Combine imageinfo requests by setting up a new class like LinkCache to request them all centrally

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

Patch-For-Review

I don't think that batching imageinfo requests goes quite far enough. I'd like to eliminate this API request from the critical path.

Let's assume that every image whose file name matches /\.svg/ is type=DRAWING type and that all other images are bitmaps. Although not guaranteed to be reliable, in practice this heuristic will almost always be correct. We should only attempt to validate our guess with an API request when the user attempts to resize the image. (This may mean that we have to scale the image back down after allowing the user to scale it up. Such cases should be exceedingly rare, however.)

The original dimensions of bitmap images should ideally be part of the paction=parse response from the API. We could also include them in the MediaWiki read HTML as data-* attributes. (This approach would take 30 days to propagate fully, but I think that's OK.)

There are two Parsoid bug/feature requests that prevent us from eliminating the API calls:

  1. We need the original dimensions and image type of the image. If Parsoid can give it to us in the data that will solve the issue.
  2. Right now, Parsoid hard-codes the image default size to 220, which is the enwiki size default. That, however, is not the default of all wikis (and definitely not standalone) so we have to resize the image. This requires us to get the original dimensions and file type (since many resize rules depend on whether the image is bitmap or drawing) which leads to API requests.

If #1 is solved, we shouldn't need an API request on load for existing images.

Change 180228 merged by jenkins-bot:
Combine imageinfo requests

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

Jdforrester-WMF renamed this task from Combine (or defer until needed?) imageinfo requests on load to Combine imageinfo requests on load.Feb 2 2015, 8:14 PM
Jdforrester-WMF moved this task from Blocked to FY 18-19 Q3/Q4 on the VisualEditor board.

Change 716268 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/VisualEditor@master] Remove redundant initialization from LinkCache

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

Change 716268 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Remove redundant initialization from LinkCache

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