Page MenuHomePhabricator

<mapframe> JavaScript runtime error
Closed, ResolvedPublicPRODUCTION ERROR


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.

Event Timeline

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 (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.

At German Wikivoyage we are using an additional JavaScript library,, which is calling 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": "",
	"KartographerIconServer": "",
	"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.

T197655.jpg (617×1 px, 110 KB)

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

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( [ '' ] ).then( function() { ... } );
mw.loader.using( [ '' ] ).done( function() {
  /* This callback is invoked as soon as the modules are available. */
} );

ie the callback function will never be called.

wgKartographerMapServer is provided by module ext.kartographer, which is a dependency of, 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

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

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