Page MenuHomePhabricator

Uncaught Error: Set map center and zoom first on mobile domain Android
Closed, ResolvedPublic

Description

This is now the most common production error unrelating to gadgets
600 errors are occuring every 12 hrs on mediawiki.org alone.

Example stack trace:

at NewClass._checkIfLoaded  https://m.mediawiki.org/w/load.php?lang=en&modules=mapbox%2Coojs-ui-core%2Coojs-ui-widgets&skin=minerva&version=1l175:45:631
at NewClass.getPixelOrigin  https://m.mediawiki.org/w/load.php?lang=en&modules=mapbox%2Coojs-ui-core%2Coojs-ui-widgets&skin=minerva&version=1l175:40:699
at NewClass.layerPointToLatLng  https://m.mediawiki.org/w/load.php?lang=en&modules=mapbox%2Coojs-ui-core%2Coojs-ui-widgets&skin=minerva&version=1l175:41:730
at NewClass.containerPointToLatLng  https://m.mediawiki.org/w/load.php?lang=en&modules=mapbox%2Coojs-ui-core%2Coojs-ui-widgets&skin=minerva&version=1l175:42:446
at NewClass._update  https://m.mediawiki.org/w/load.php?lang=en&modules=mapbox%2Coojs-ui-core%2Coojs-ui-widgets&skin=minerva&version=1l175:173:653
at NewClass.fire  https://m.mediawiki.org/w/load.php?lang=en&modules=mapbox%2Coojs-ui-core%2Coojs-ui-widgets&skin=minerva&version=1l175:9:862
at NewClass._onPanTransitionStep  https://m.mediawiki.org/w/load.php?lang=en&modules=mapbox%2Coojs-ui-core%2Coojs-ui-widgets&skin=minerva&version=1l175:51:537
at NewClass.fire  https://m.mediawiki.org/w/load.php?lang=en&modules=mapbox%2Coojs-ui-core%2Coojs-ui-widgets&skin=minerva&version=1l175:9:862
at NewClass._runFrame  https://m.mediawiki.org/w/load.php?lang=en&modules=mapbox%2Coojs-ui-core%2Coojs-ui-widgets&skin=minerva&version=1l175:62:524
at NewClass._step  https://m.mediawiki.org/w/load.php?lang=en&modules=mapbox%2Coojs-ui-core%2Coojs-ui-widgets&skin=minerva&version=1l175:62:329

Seems to be occurring on the mobile domain (likely should be tested using a real device).
https://logstash.wikimedia.org/goto/9a71fe228bff5b2dab8107718fef37b0

Replication steps: T257872#6314259

Event Timeline

Jdlrobson renamed this task from Uncaught Error: Set map center and zoom first on mobile domain Android 6.0.1 to Uncaught Error: Set map center and zoom first on mobile domain Android.Jul 17 2020, 12:15 AM
Jdlrobson edited projects, added Maps (Kartographer); removed Maps.
Jdlrobson triaged this task as High priority.EditedJul 17 2020, 12:35 AM
Jdlrobson added a subscriber: TheDJ.

This is the highest bug contributor that I am aware of right now - 609 on Catalan Wikipedia in the last 30 mins alone - and it seems to happen on a single browser in a short space of time.

I imagine what's happening is a single person is using it on a poor connection.

I can replicate this by the following steps:

  1. Visit https://ca.m.wikipedia.org/wiki/Illinois#/map/0 on Chrome with "Slow 2G". Using the same menu prime yourself to switch to offline.
  2. As soon as the map appears trigger the offline
  3. Pan to begin the errors.

@MSantos @TheDJ any idea how we can avoid this?

mapissue.gif (380×640 px, 3 MB)

I'm not sure who maintains this extension but I think it's pretty urgent we address this given the traffic this can potentially send to our client side error tracking, especially if we want to roll it out further.

That seems to be deep inside the mapbox/leaflet JS library itself...

Maps load AFTER the ooui window opens (because it needs to size to fit and it's pretty dumb about that). But apparently leaflet/mapbox throws this exception on every move event triggered in the viewport without a map.. I guess we can put an event blocker on that surface early on, which we then undo AFTER the map is set ?

My read of the stack trace was that map.initView( options.center, options.zoom ); is not getting called after a failed api request. If the api request fails no center or zoom ever gets set. Is there anywhere in the code that map.initView is called in an asynchronous callback that might fail which is not error handled?

Change 614867 had a related patch set uploaded (by TheDJ; owner: TheDJ):
[mediawiki/extensions/Kartographer@master] Ensure the map is initialized if external data fails

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

Change 614867 merged by jenkins-bot:
[mediawiki/extensions/Kartographer@master] Ensure the map is initialized if external data fails

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

Jdlrobson added a project: User-Jdlrobson.

I'll follow up on Thursday if this makes a difference or needs to remain open :)

I think it will. I tested it by simply commenting out the usual data groups logic. Ideally however, we would want to inform the end-user that an error occurred and not just the console... Unfortunately, there is no current strategy for this, I have created T258477 for this purpose.

Out of interest.. what does Minerva/MF usually use when a resource loading error occurs for functionality ? retry, present an error notification ?

Unfortunately I'm afraid this is till happening - 24,279 events in the last 12hrs on wikis with your patch from a handle of IPs :-(. I am able to replicate this using GPRS and attempting to pan/zoom before the map loads on https://ca.m.wikipedia.org/wiki/Pant%C3%A0_de_Serrateix#/map/0

Is there a way we can display: none the map until we are certain it is loaded? Perhaps something like

// css
document.querySelector('.mw-kartographer-mapDialog-map').style.display = 'none';

map.on('sourcedata', (e)=> {
    if (map.loaded()) {
         document.querySelector('.mw-kartographer-mapDialog-map').style.display = 'block';
    }
})

This is unfortunately going to block us rolling out client side error tracking on larger wikis so am keen to find some way of avoiding this error from ever occurring.

Out of interest.. what does Minerva/MF usually use when a resource loading error occurs for functionality ? retry, present an error notification ?

We're quite bad at this. In best cases we use mw.notify or show an error, but at worse, we do nothing and show a blank screen (just haven't had time to priortise fixing those)

I think here the issue is not a user error per se - the code is just getting into an error state.

Unfortunately I'm afraid this is till happening - 24,279 events in the last 12hrs on wikis with your patch from a handle of IPs :-(. I am able to replicate this using GPRS and attempting to pan/zoom before the map loads on https://ca.m.wikipedia.org/wiki/Pant%C3%A0_de_Serrateix#/map/0

Is there a way we can display: none the map until we are certain it is loaded? Perhaps something like

// css
document.querySelector('.mw-kartographer-mapDialog-map').style.display = 'none';

map.on('sourcedata', (e)=> {
    if (map.loaded()) {
         document.querySelector('.mw-kartographer-mapDialog-map').style.display = 'block';
    }
})

This is unfortunately going to block us rolling out client side error tracking on larger wikis so am keen to find some way of avoiding this error from ever occurring.

Out of interest.. what does Minerva/MF usually use when a resource loading error occurs for functionality ? retry, present an error notification ?

We're quite bad at this. In best cases we use mw.notify or show an error, but at worse, we do nothing and show a blank screen (just haven't had time to priortise fixing those)

I think here the issue is not a user error per se - the code is just getting into an error state.

@Jdlrobson I can't reproduce, maybe you got some sort of cache? Could you confirm?

I can still replicate with disable cache ticked (here's a gif to show it happening I just recorded) and 7,425 errors have been reported using our client side error tracking in the last 24hrs - so definitely an issue and not cache related. This remains the most prominent of JS errors on production because of the fact a single client sends multiple errors indefinitely when it gets into this state.

To be clearer - this is really hard to replicate without being able to simulate a slow or dropped connection. It happens somewhere in the loading stages of the map - when the zoom controls are visible but not the map tiles - so far I seem to be able to replicate this with a quick reaction time to swipe to pan with a GPRS simulated connection on Catalan Wikipedia. With Mapbox is it possible to delay the enabling of panning/zooming until after the map has "loaded" ?

bug.gif (308×640 px, 679 KB)

Change 617286 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/extensions/Kartographer@master] Set map center and zoom on creation

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

Change 617286 merged by jenkins-bot:
[mediawiki/extensions/Kartographer@master] Disable panning and zooming until ready

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

Change 617429 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/extensions/Kartographer@wmf/1.36.0-wmf.2] Disable panning and zooming until ready

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

Change 617429 merged by jenkins-bot:
[mediawiki/extensions/Kartographer@wmf/1.36.0-wmf.2] Disable panning and zooming until ready

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

Mentioned in SAL (#wikimedia-operations) [2020-07-30T18:32:35Z] <urbanecm@deploy1001> Synchronized php-1.36.0-wmf.2/extensions/Kartographer/modules/box/Map.js: rEKARaa3dbd54f8e4: Disable panning and zooming until ready (T257872) (duration: 01m 06s)

So far so good. No errors in the last 30 mins since the backport.

No errors in last 12 hrs. Will leave this open until I've seen the effect on English Wikipedia.

I've not seen this error in over 24hrs on Catalan Wikipedia. Hurray! Thanks for the help fixing this @MSantos and @TheDJ .