Page MenuHomePhabricator

[Regression wmf.16] Switching to VE from Wikitext editor is failing on mobile, shows error "TypeError: Cannot read property 'saveFields' of null"
Closed, ResolvedPublic


Steps to reproduce:

  1. Go to this page:
  2. Click on the pencil icon
  3. If it opens VE, switch to wikitext mode
  4. Now try to switch back to VE, it loads the editor dialog but doesn't really switch to VE

The following error appears on the console:
TypeError: Cannot read property 'saveFields' of null

Event Timeline

Ryasmeen created this task.Feb 6 2019, 12:46 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptFeb 6 2019, 12:46 AM

I can't reproduce this. Does it still happen for you? If so, can you copy-paste the error backtrace too?

I note that the error message is identical to T213338.

I found a different issue though while trying to reproduce this, switching in the opposite direction fails for me: T215408

Go to any page (e.g. - switch to an edit mode - and switch between VE and wikitext (might take several switches).

TypeError: Cannot read property 'saveFields' of null
    at <anonymous>:193:327
    at fire (load.php?debug=false&lang=en&modules=jquery&skin=minerva&version=00rdyep:45)
    at Object.add (load.php?debug=false&lang=en&modules=jquery&skin=minerva&version=00rdyep:46)
    at <anonymous>:193:293
    at runScript (load.php?debug=false&lang=en&modules=startup&only=scripts&skin=minerva&target=mobile:12)
    at execute (load.php?debug=false&lang=en&modules=startup&only=scripts&skin=minerva&target=mobile:14)
    at doPropagation (load.php?debug=false&lang=en&modules=startup&only=scripts&skin=minerva&target=mobile:7)

I reproduced this accidentally but I'm not sure how. I will poke at it a bit more.

Okay, steps to reproduce:

  1. Be on a wmf.14 wiki (currently is still on wmf.14 for some reason, although it should be on wmf.16, which confused me)
  2. Have the visual editor as default
  3. Go to any page, open the mobile editor
    • (the error only occurs if visual editor opens first; if the wikitext editor opens, switch to visual to change your default, then close it and refresh the page)
  4. Switch to wikitext
  5. Switch back to visual

What happens is:

In step 3, visual editor code is loaded from resources/mobile.editor/init.js like this:

loader.loadModule( '' )`.

Most importantly, this does not load any plugins, such as ext.wikimediaEvents.visualEditor ([mw/ext/WikimediaEvents]/modules/ve-wme/campaigns.js), where the exception comes from.

When visual editor is set up, it fires the 've.activationComplete' hook. But the code above is not loaded, so it doesn't run.

In step 5, visual editor code is loaded from resources/mobile.editor.overlay/EditorOverlay.js like this:

mw.loader.using( 'ext.visualEditor.targetLoader' ).then( function () { '' );
	return 'visual' );
} )

And this does load plugins, including ext.wikimediaEvents.visualEditor.

When this code is loaded, the plugin's code is immediately executed, and because of memorization in mw.hook, the handler for 've.activationComplete' hook defined therein is also immediately executed! But there is no target set up at this point (we're still in the middle of loading VE code, before we started setting up the editor), and everything fails horribly.

The good news us: turns out we have already accidentally fixed this issue. In 5f7cbd16c9bb5ff5d9b29393d538f7c81f19a784 (, the code in resources/mobile.editor/init.js (which was renamed to src/mobile.init/editor.js) has been changed to use the same method as EditorOverlay.js, so now it loads the plugins. That means this bug can no longer occur on wmf.16, and that is why I could not reproduce it (I tested on a local wiki running master, and then on test.wp running wmf.16).

The bad news is: not loading the plugins is actually a major bug and I am confused how it was not noticed before. For example, the Cite extension implements our support for references as a plugin. Was using references in mobile VE really unavailable for all this time, except when it was loaded by switching from wikitext editor?

matmarex added a project: Regression.
matmarex moved this task from Incoming to QA on the VisualEditor (Current work) board.

(should be already fixed in wmf.16)

matmarex claimed this task.Feb 6 2019, 8:48 PM
Esanders moved this task from Inbox to High Priority on the Editing QA board.Feb 7 2019, 7:05 PM
Ryasmeen moved this task from QA to Product owner review on the VisualEditor (Current work) board.
Ryasmeen removed a project: Editing QA.
ppelberg closed this task as Resolved.Feb 14 2019, 11:45 PM
Restricted Application added a project: User-Ryasmeen. · View Herald TranscriptFeb 14 2019, 11:45 PM