Page MenuHomePhabricator

Don't always request static snapshots when previewing mapframes
Closed, ResolvedPublic

Description

When you preview an article that includes a mapframe there always seems to be snapshot request to the map servers although the preview is not the static image.

These requests neither contain the page title nor the groupid. Therefore they can only show the plain base map and autopositon or autozoom can not be applied. Doing the latter will currently also lead to an error response from the mapserver.

Requesting the static snapshot is defenitly a fallback for non JavaScript users and it might make sense to keep it in all cases there. But the current setup does not allow a snapshot generation from unsaved wikitext. So in most cases the snapshot would only display the base map without features.

Things to do here:

  • Avoid the failing requests that contain autopostion/-zoom
  • Dont request snapshots when JS is available

Event Timeline

Currently there seem to be some limited use for static snapshots if previewing in VisualEditor. That is if mapframe is generated via wrapper template and map is without JSON overlay. E.g. if I edit map in the following article then new snapshot is visible in preview:
https://et.wikipedia.org/wiki/Johan_Laidoneri_plats?veaction=edit
(If such map has JSON overlay and is edited in VisualEditor then just broken mapframe without any image is displayed in preview, partly because we wanted to avoid a defective snapshot preview getting cached in case autopositioning is used.)

Which makes me wonder why dynamic mapframe content isn't loaded in VisualEditor preview in case there's a wrapper template. Could it be loaded?

Yeah thanks for that hint. I just now played with VE and had a look at the requests fired in the background. In my examples only see a snapshot request when I try to move around a map in the WYSIWYG view. These snapshot requests relate to the original content and seem to be correct and working though. ( Although I dont see them being applied anywhere ). I guess that's for another ticket. Could be for example T323923: Preview of maps with external data is broken in VE

For now this is just about the pretty much useless snapshot in the normal preview workflow. Maybe it's connected.

awight subscribed.

Prioritizing into the current sprint, since it's our most common error by far.

Change 886803 had a related patch set uploaded (by Awight; author: Awight):

[mediawiki/extensions/Kartographer@master] Omit static thumbnail in preview mode

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

Questions:

  • What about clients where JavaScript is disabled?
  • What about maps that show nothing but a piece of the base map, but don't contain any data? These can always be rendered. Such requests would not even be wasted because they do not change after the page is saved.

Questions:

  • What about clients where JavaScript is disabled?

Good point. The plain snapshot request seems to be the fallback for these users. The current patch breaks the preview in that case. But regarding maps that uses autoposition or autozoom these also look broken at the moment and trigger server errors. I wonder if we could still avoid that request when we know that JS will be delivered.

A fallback could of cause be always showing the currently saved version here but that will be irritating if a non JS users actually edits mapframe content and expects his changes in the preview then. So I guess that option would at least need to include a note somewhere, that the map previews can only be generated correctly with JS.

  • What about maps that show nothing but a piece of the base map, but don't contain any data? These can always be rendered. Such requests would not even be wasted because they do not change after the page is saved.

A general exception for maps without data could help in all cases of cause. And a broken preview when users try to use autoposition or autozoom just reflects what would happen when saving the map then.

Change 886803 merged by jenkins-bot:

[mediawiki/extensions/Kartographer@master] Omit impossible static thumbnail in preview mode

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

WMDE-Fisch renamed this task from Don't request a static snapshot when previewing mapframes to Don't always request static snapshots when previewing mapframes.Feb 8 2023, 9:42 AM
WMDE-Fisch updated the task description. (Show Details)

We did the minimal thing that could be done straight forward here to at least lift some burden on the servers and fix the error spam. It's mostly not user facing. Further work could be:

  • Avoiding requests on maps with features ( Or there should at least be a hint for the user. Either why the previewed map has no features or why there's no previewed map. )
  • Finding a way to only request the snapshot for non JS users.

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

[mediawiki/extensions/Kartographer@master] Use <noscript> in preview to avoid pointless snapshot requests

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

Finding a way to only request the snapshot for non JS users.

That's a surprisingly old HTML feature: <noscript>.

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

[mediawiki/extensions/Kartographer@master] No need for an empty <div> when a static map isn't available

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

Change 888655 merged by jenkins-bot:

[mediawiki/extensions/Kartographer@master] No need for an empty <div> when a static map isn't available

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

Change 888643 merged by jenkins-bot:

[mediawiki/extensions/Kartographer@master] Use <noscript> in preview to avoid pointless snapshot requests

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

thiemowmde claimed this task.