Page MenuHomePhabricator

Combine imageinfo requests on load
Closed, ResolvedPublic8 Estimated Story Points


  1. Go to 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 created this task.Nov 25 2014, 3:28 AM
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 added a subscriber: Catrope.
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


Krenair claimed this task.Dec 16 2014, 10:16 PM
ori moved this task from Backlog to Doing on the VisualEditor-Performance board.Jan 23 2015, 7:49 AM
ori added a subscriber: ori.Feb 2 2015, 5:25 AM

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

Jdforrester-WMF edited a custom field.Feb 2 2015, 7:44 PM
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 Q4 on the VisualEditor board.
ori moved this task from Doing to Done on the VisualEditor-Performance board.Feb 21 2015, 6:12 AM