Page MenuHomePhabricator

Maps live preview is broken on 2nd attempt
Closed, ResolvedPublicBUG REPORT


  • in your user preferences / editing tab, enable "Use live preview" (at the bottom) and save
  • edit source a page with a mapframe
  • click preview (the preview appears at the top) - check that everything is still ok
  • click preview again - now the map is shifted to the upper left corner inside the mapframe
On first previewOn second preview
pasted_file (393×384 px, 99 KB)
pasted_file (403×386 px, 23 KB)

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 348657 had a related patch set uploaded (by JGirault):
[mediawiki/core@master] Live Preview: Attach to the DOM before 'wikipage.content'

I can reproduce the described behavior on but I can not reproduce the behavior on a local wiki. When I add $wgUsejQueryThree = false; to the LocalSettings.php then I can reproduce the behavior. It seams that jQuery 3 fix the problem.

Change 348657 abandoned by Krinkle:
Live Preview: Attach to the DOM before 'wikipage.content'

The proposed solution using requestAnimationFrame (or L.Util.requestAnimFrame) works, but I am being careful to not break something. It's gonna require me more testing.

debt removed JGirault as the assignee of this task.Jun 6 2017, 7:51 PM
debt moved this task from Stalled/Waiting to Backlog on the Maps-Sprint board.
debt removed a project: Patch-For-Review.
debt added a subscriber: debt.

Moving to backlog until such time that we can take this up again.

Moving off the sprint board - the Discovery team won't be able to do this work at this time.

It is interesting why jQuery 3 solves this problem.

@Fomafix - would you be able to help fix this bug? Unfortunately, the Maps team doesn't have resources to do it right now.

As far as I see is this problem fixed when T124742 is enabled. It is interesting why jQuery 3 solves this problem and of course where is the problem exactly.

@Fomafix - great! I'll go ahead and decline this particular task then, since it'll be fixed with T124742's release.

This task is still valid, but it is needs to wait for the jQuery update. Reopening and making it the parent of the other one.

The problem is most likely that Kartographer JS code is trying to do something to the page before the dialog finishes loading.

jQuery 3 hides (not solves!) this problem because it calls promise callbacks asynchronously, so they happen slightly later now, and it just luckily for Kartographer now runs when the dialog is ready.

Note, opening the maps modal also triggers the below OOjs UI warning (T166729):

Using the return value of openWindow as a promise is deprecated. Use .openWindow( ... ).opening.then( ... ) instead.

With jQuery 3 I see on the second live preview the following error message in the JavaScript console when I hover the map:

Error: Invalid LatLng object: (NaN, NaN) mapbox-lib.js:1231:9

Maybe this is the same reason.

For the record, I can still reproduce this issue on when following the steps in the task description.

Fomafix changed the subtype of this task from "Task" to "Bug Report".Mar 2 2019, 2:14 PM

Change 588459 had a related patch set uploaded (by TheDJ; owner: TheDJ):
[mediawiki/extensions/Kartographer@master] Use requestAnimationFrame to fix livepreview problem

Jdlrobson added a subscriber: Jdlrobson.*/logstash-2020.09.09/clienterror/?id=AXR0cOQp3_NNwgAUScPH

at new L.LatLng  URL1:175:442
at Object.unproject  URL1:180:333
at Object.pointToLatLng  URL1:180:826
at NewClass.unproject  URL1:195:615
at NewClass.layerPointToLatLng  URL1:195:760
at NewClass._fireDOMEvent  URL1:202:145
at NewClass._handleDOMEvent  URL1:201:409
at HTMLAnchorElement.handler  URL1:211:775


T280363 is about maplinks. T151524 is about mapframe. These are separate bugs.

Krinkle renamed this task from Maps fast preview is broken on 2nd attempt to Maps live preview is broken on 2nd attempt.Aug 18 2021, 9:40 PM

Change 588459 merged by jenkins-bot:

[mediawiki/extensions/Kartographer@master] Use requestAnimationFrame to fix livepreview problem

TheDJ claimed this task.