Last modified: 2014-04-06 13:25:29 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T61808, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 59808 - Scribunto pulls in jquery.ui.dialog for error reporting
Scribunto pulls in jquery.ui.dialog for error reporting
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Scribunto (Other open bugs)
unspecified
All All
: Low normal (vote)
: ---
Assigned To: Nobody - You can work on this!
: performance
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-01-08 00:53 UTC by Jon
Modified: 2014-04-06 13:25 UTC (History)
14 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Jon 2014-01-08 00:53:44 UTC
On wiki's with Scribunto installed, when viewed in the mobile site, the exception "Uncaught Error: Unknown dependency: ext.scribunto" is thrown which prevents any further JavaScript from running.

This is because the module is not registered on mobile.

It also depends on jquery.ui.dialog code which pulls in the entire jquery.ui library - we certainly do not want on mobile where JavaScript load should be as tiny as possible.

I doubt we'd want to run this code on mobile thus the use of addInlineScript needs to be avoided since the module doesn't exist in the mobile environment. At the very least it should be wrapped with a try catch so say it is acceptable to fail.

Seems to have been introduced by https://gerrit.wikimedia.org/r/#/c/5617/1,publish
Comment 1 Jon 2014-01-08 00:59:52 UTC
Okay this doesn't look so bad now as it seems to only become a problem when a ScribuntoError occurs (I'm not sure how often this occurs on wiki's - I've only managed to replicate this locally). However it seems bizarre to me that the entire jQuery UI library would be loaded simply for error reporting...
Comment 2 This, that and the other (TTO) 2014-01-21 11:19:59 UTC
Realistically, Scribunto does not require the full jQuery UI. I feel that it should roll its own "script error" popup, since jQuery UI Dialogs were not really designed for this use.
Comment 3 Brad Jorsch 2014-01-22 19:59:28 UTC
What's the point of having jQuery if we're not supposed to use it?
Comment 4 Ryan Kaldari 2014-01-22 20:26:01 UTC
For desktop, jQuery UI is fine (at least until OO.js is more widely adopted). The only problem is that mobile doesn't want to load jQuery UI unless absolutely necessary, and Scribunto is used on both desktop and mobile.

There are two possible short-term solutions:
* Make jquery.ui and jquery.ui.dialog loadable on mobile by giving them the 'mobile' target in the module definition (and make sure they are only loaded when there is an error)
* Remove the dialog code from Scribunto and just use a JS alert in the meantime. Alerts are pretty unfriendly (since they take over the browser, stop JS execution, etc.), but since it's such a limited use, it might be OK for a short-term fix.
Comment 5 Jon 2014-01-22 21:11:06 UTC
jQuery UI != jQuery
Use jQuery by all means of a jQuery plugin for this - you do not need a huge library the size of jQuery UI.

jQuery UI is totally unsuitable for mobile. Please do not load it to simply use I'd guess about 2% of the library..

As stated the correct thing to do would be to start using OO.js which is in core.
Comment 6 Jon 2014-01-22 21:12:35 UTC
In case I was clear please do not follow Ryan's suggestion of 
"Make jquery.ui and jquery.ui.dialog loadable on mobile by giving them the
'mobile' target in the module definition (and make sure they are only loaded
when there is an error)"

An alert would make more sense, using jQuery UI is overkill for this use case imo.
Comment 7 Brad Jorsch 2014-01-22 21:14:42 UTC
(In reply to comment #4)
> * Remove the dialog code from Scribunto and just use a JS alert in the
> meantime. Alerts are pretty unfriendly (since they take over the browser,
> stop
> JS execution, etc.), but since it's such a limited use, it might be OK for a
> short-term fix.

I believe some browsers are starting to block alters entirely.

(In reply to comment #5)
> As stated the correct thing to do would be to start using OO.js which is in
> core.

Patches welcome. Or even links to examples.
Comment 8 Ryan Kaldari 2014-01-22 21:44:37 UTC
OOjs is in core, but if you want to make dialogs, you probably need OOjs UI as well, which is still only in VisualEditor.
Comment 9 Tim Starling 2014-01-22 21:46:49 UTC
One problem with alert() is that it's not HTML, so you couldn't click on the source file links which appear in the Scribunto backtraces.

(In reply to comment #1)
> Okay this doesn't look so bad now as it seems to only become a problem when a
> ScribuntoError occurs (I'm not sure how often this occurs on wiki's - I've
> only managed to replicate this locally). 

You can replicate it on the pages in this category:

https://en.wikipedia.org/wiki/Category:Pages_with_script_errors

It looks like there are currently no such pages in the main namespace, so the impact of this bug on readers of en.m.wikipedia.org is negligible.

There's a bug in Scribunto which causes jquery.ui.dialog and the hidden category to be added even if no errors are emitted into the final HTML, say due to the error being sent to the condition of a {{#iferror:}}. At one point, there were tens of thousands of pages in [[Category:Pages with script errors]] for no obvious reason, possibly due to that bug. So, it would have affected mobile readers at that time. That could be reported separately if it's not already.

> However it seems bizarre to me that the
> entire jQuery UI library would be loaded simply for error reporting...

I think error reporting is the most important feature in Scribunto, it's central to the usability of Lua scripting. So I don't think it's bizarre that it loads libraries. It's just somewhat inefficient. 

I would be fine with a lightweight DIY thing, or with dynamic loading of jquery.ui.dialog on click of the error message, with a spinner.
Comment 10 Derk-Jan Hartman 2014-01-22 21:57:32 UTC
let's just dynamically load it, it's simple and not too many 'normal' users are using it anyways. When OOjs is more mature, we can just switch it over.
Comment 11 Tim Starling 2014-01-22 21:59:22 UTC
Updated summary since of course it doesn't pull in the whole of jQuery UI, it pulls in jquery.ui.dialog and (implicitly) its 7 dependencies, so 8 out of the 17 JavaScript files in resources/jquery.ui/
Comment 12 Gerrit Notification Bot 2014-01-24 01:02:06 UTC
Change 109262 had a related patch set uploaded by TheDJ:
Conditionally load jquery.ui.dialog for Scribuntu errors

https://gerrit.wikimedia.org/r/109262
Comment 13 Gerrit Notification Bot 2014-03-16 02:50:24 UTC
Change 118944 had a related patch set uploaded by Hoo man:
Don't try to (inline load) ext.scribunto if it isn't registered

https://gerrit.wikimedia.org/r/118944
Comment 14 Gerrit Notification Bot 2014-03-26 18:18:09 UTC
Change 118944 merged by jenkins-bot:
Don't try to inline load ext.scribunto on mobile

https://gerrit.wikimedia.org/r/118944
Comment 15 Jon 2014-03-26 18:21:15 UTC
I'd still advise you to move away from jquery.ui but this is not effecting mobile now so I am happy.
Comment 16 Gerrit Notification Bot 2014-04-06 13:25:29 UTC
Change 109262 abandoned by TheDJ:
Conditionally load jquery.ui.dialog for Scribunto errors

Reason:
Fixed with: https://gerrit.wikimedia.org/r/#/c/118944/

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

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links