Page MenuHomePhabricator

<mapframe> JavaScript runtime error
Closed, ResolvedPublic

Description

Chrome and Opera browsers show a Javascript runtime error while creating a <mapframe> map. The map creation is stopped, it is not dynamical (i.e. the map is "freezed"). This bug is accidental but frequent.

The error log:

Exception in module-execute in module ext.kartographer.settings:
load.php?debug=false&lang=de&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=18kdz1s:175 TypeError: Cannot read property '4' of null
    at <anonymous>:19:342
    at <anonymous>:19:525
    at runScript (load.php?debug=false&lang=de&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=18kdz1s:160)
    at checkCssHandles (load.php?debug=false&lang=de&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=18kdz1s:161)
    at execute (load.php?debug=false&lang=de&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=18kdz1s:162)
    at Object.implement (load.php?debug=false&lang=de&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=18kdz1s:168)
    at <anonymous>:19:170
    at domEval (load.php?debug=false&lang=de&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=18kdz1s:159)
    at load.php?debug=false&lang=de&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=18kdz1s:165

It seems that there is a programmer's bug in /Kartographer/modules/settings/settings.js

( function ( $, mw ) {

	var mapServer = mw.config.get( 'wgKartographerMapServer' ),
		forceHttps = mapServer[ 4 ] === 's',
		config = L.mapbox.config;

	config.REQUIRE_ACCESS_TOKEN = false;
	config.FORCE_HTTPS = forceHttps;
	config.HTTP_URL = forceHttps ? false : mapServer;
	config.HTTPS_URL = !forceHttps ? false : mapServer;

}( jQuery, mediaWiki ) );

If wgKartographerMapServer is not set for whatever reason (mapServer is nil) then you cannot perform mapServer[ 4 ] === 's'.

It is unknown to me why this problem occurs only in Chrome-based browsers.

Details

Related Gerrit Patches:
mediawiki/extensions/Kartographer : masterFix Exception in ext.kartographer.settings module

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJun 19 2018, 9:38 AM

Both on German and English Wikivoyage branches you can look for pages which are linked to the mapframe template to find examples for check.

Normally, wgKartographerMapServer is a global variable set to https://maps.wikimedia.org (defined in Kartographer/extension.json). I do not know why the wgKartographerMapServer variable is missing.

On my Android smartphone with Chrome 67.0, I can switch the mapframe to full screen, but sometimes there are no icons on the full screen view.

Restricted Application added a project: Performance-Team. · View Herald TranscriptJun 20 2018, 4:47 AM

At German Wikivoyage we are using an additional JavaScript library, https://de.wikivoyage.org/wiki/MediaWiki:MapTools.js, which is calling ext.kartographer.box in a manner as described in the documentation. I switched it off, and the runtime error/exception occurred furthermore.

The config variables like wgKartographerMapServer are not set in the document header. I think they will be set by the ResourceLoader because they are noted only in extension.json.

"config": {
	"KartographerStaticMapframe": false,
	"KartographerWikivoyageMode": false,
	"KartographerDfltStyle": "osm-intl",
	"KartographerStyles": ["osm-intl", "osm"],
	"KartographerSrcsetScales": [1.3, 1.5, 2, 2.6, 3],
	"KartographerMapServer": "https://maps.wikimedia.org",
	"KartographerIconServer": "https://maps.wikimedia.org",
	"KartographerFrameMode": "interactive",
	"KartographerUseMarkerStyle": false,
	"KartographerEnableMapFrame": true
},

The JavaScript (for the mapframe map, too) is performed "on load" (on ready). It seems that the variables needed are not available at this time.


The image shows a <mapframe> map without controls and the error log given by Opera 53.0.

Vvjjkkii renamed this task from <mapframe> JavaScript runtime error to woaaaaaaaa.Jul 1 2018, 1:03 AM
Vvjjkkii triaged this task as High priority.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed a subscriber: Aklapper.
JJMC89 renamed this task from woaaaaaaaa to <mapframe> JavaScript runtime error.Jul 1 2018, 1:56 AM
JJMC89 raised the priority of this task from High to Needs Triage.
JJMC89 updated the task description. (Show Details)
JJMC89 added a subscriber: Aklapper.

If such a runtime error occur then the folowing loader functions fail:

mw.loader.using( [ 'ext.kartographer.box' ] ).then( function() { ... } );
  or
mw.loader.using( [ 'ext.kartographer.box' ] ).done( function() {
  /* This callback is invoked as soon as the modules are available. */
} );

ie the callback function will never be called.

TheDJ added a subscriber: TheDJ.Jul 9 2018, 3:26 PM

wgKartographerMapServer is provided by module ext.kartographer, which is a dependency of ext.kartographer.box, but is not a dependency of ext.kartographer.settings. That seems like a mistake in the RL definitions indeed.

At the travellers' pub at the English Wikivoyage edition another fault scenario was reported: If now zoom parameter is set (auto-zoom mode) a world map is displayed instead of a location map. It seems that the runtime error explained prevents the calculation of map center and zoom.

If no zoom parameter should read instead of If now zoom parameter.

Krinkle added a subscriber: Krinkle.

As @TheDJ found, this is not a problem with ResourceLoader framework or its logic. The Kartographer seems to be missing an implicit dependency between two of of its modules.

Change 449619 had a related patch set uploaded (by TheDJ; owner: TheDJ):
[mediawiki/extensions/Kartographer@master] Fix Exception in ext.kartographer.settings module

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

TheDJ triaged this task as Low priority.Jul 31 2018, 10:11 PM

Change 449619 merged by jenkins-bot:
[mediawiki/extensions/Kartographer@master] Fix Exception in ext.kartographer.settings module

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

Krinkle removed a project: Patch-For-Review.
MSantos moved this task from Backlog to To-do on the Maps-Sprint board.Sep 18 2018, 6:18 PM
MSantos moved this task from Unsorted to General on the Maps (Kartographer) board.Sep 25 2018, 3:07 PM
MSantos closed this task as Resolved.Sep 25 2018, 8:07 PM
MSantos claimed this task.
MSantos added a subscriber: MSantos.

It seems to be resolved, feel free to reopen in case the problem occurs again or is still happening.

mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:09 PM