mozilla / qbrt

CLI to a Gecko desktop app runtime
Apache License 2.0
391 stars 31 forks source link

qbrt fails to start #170

Open benfrancis opened 5 years ago

benfrancis commented 5 years ago

STR:

Error:

JavaScript error: file:///home/tola/.nvm/versions/node/v8.11.3/lib/node_modules/qbrt/dist/linux/runtime/qbrt/components/DisabledAddonManager.js, line 24: TypeError: XPCOMUtils.generateQI is not a function
JavaScript error: file:///home/tola/.nvm/versions/node/v8.11.3/lib/node_modules/qbrt/dist/linux/runtime/qbrt/components/DisabledTelemetryStartup.js, line 14: TypeError: XPCOMUtils.generateQI is not a function
JavaScript error: file:///home/tola/.nvm/versions/node/v8.11.3/lib/node_modules/qbrt/dist/linux/runtime/qbrt/components/CommandLineHandler.js, line 42: TypeError: XPCOMUtils.generateQI is not a function

Tested on Ubuntu 18.04 LTS.

patrickalima98 commented 5 years ago

Same problem here STR:

Error:

JavaScript error: file:///C:/Users/patri/AppData/Roaming/npm/node_modules/qbrt/dist/win32/runtime/qbrt/components/DisabledAddonManager.js, line 24: TypeError: XPCOMUtils.generateQI is not a function
JavaScript error: file:///C:/Users/patri/AppData/Roaming/npm/node_modules/qbrt/dist/win32/runtime/qbrt/components/DisabledTelemetryStartup.js, line 14: TypeError: XPCOMUtils.generateQI is not a function
JavaScript error: file:///C:/Users/patri/AppData/Roaming/npm/node_modules/qbrt/dist/win32/runtime/qbrt/components/CommandLineHandler.js, line 42: TypeError: XPCOMUtils.generateQI is not a function
JavaScript error: resource://gre/modules/ActorManagerChild.jsm, line 269: TypeError: singletons is null

Tested on Windows 10 x64 Version 1809

rafaelmr2 commented 5 years ago

Same here in Manjaro.

MattGyverLee commented 5 years ago

Me too.

MattGyverLee commented 5 years ago

It's a Mozilla issue: https://github.com/mozilla/tls-canary/issues/171

lewisthoma5 commented 5 years ago

Windows 10 same issue.

guilmour commented 5 years ago

Same here in Debian 9.8 (stretch) :crying_cat_face:

JavaScript error: file:///home/guilmour/.nvm/versions/node/v11.10.1/lib/node_modules/qbrt/dist/linux/runtime/qbrt/components/DisabledAddonManager.js, line 24: TypeError: XPCOMUtils.generateQI is not a function
JavaScript error: file:///home/guilmour/.nvm/versions/node/v11.10.1/lib/node_modules/qbrt/dist/linux/runtime/qbrt/components/DisabledTelemetryStartup.js, line 14: TypeError: XPCOMUtils.generateQI is not a function
JavaScript error: file:///home/guilmour/.nvm/versions/node/v11.10.1/lib/node_modules/qbrt/dist/linux/runtime/qbrt/components/CommandLineHandler.js, line 42: TypeError: XPCOMUtils.generateQI is not a function

Someone did get success on troubleshooting this issue?

star-buck commented 5 years ago

same on debian buster... can a fix be deployed for qrbt similar to that in the ticket above?

guilmour commented 5 years ago

@star-buck I tried that, but now I'm stuck at the error:

JavaScript error: file:///home/guilmour/gits/qbrt6/components/CommandLineHandler.js, line 28: NS_ERROR_FILE_NOT_FOUND: Component returned failure code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [nsIChannel.open2]

:/

nothingismagick commented 5 years ago

Same on MacOS

dragondaksh commented 5 years ago

Still the issue persists, please can someone tell what can be done?

star-buck commented 5 years ago

Would love to see that fixed as well. Otherwise qbrt is useless?

benfrancis commented 5 years ago

I am totally out of my depth here, but let's see where we can get with this. These errors are being generated by:

These are all in qbrt's components directory and to my untrained eye appear to be designed to stub out components that aren't used by qbrt but that Firefox (being used as a runtime) somehow expects to be there.

The errors appear to be caused by calls these components make to an XPCOMUtils.generateQI() method which no longer exists. Thunderbird apparently had the same problem and they solved it by "providing their own little generateQI implementation", which @cr didn't seem to like.

If I comment out the lines in those components which call XPCOMUtils.generateQI() (which removes the QueryInterface property of an object in each case) then XPCOMUtils.jsm complains that QueryInterface doesn't exist. Which I assume is why it's there in the first place!

JavaScript error: resource://gre/modules/XPCOMUtils.jsm, line 458: TypeError: this._instance.QueryInterface is not a function
JavaScript error: resource://gre/modules/XPCOMUtils.jsm, line 458: TypeError: this._instance.QueryInterface is not a function
JavaScript error: resource://gre/modules/XPCOMUtils.jsm, line 433: TypeError: (new component(...)).QueryInterface is not a function

...and that is as far as I have got.

benfrancis commented 5 years ago

I note that https://github.com/mozilla/tls-canary/pull/172 fixed a similar error by replacing instances of XPCOMUtils.generateQI() with ChromeUtils.generateQI().

If I do this for qbrt I no longer get the error messages above, I get a new error:

error starting runtime: [Exception... "Component does not have requested interface" nsresult: "0x80004002 (NS_NOINTERFACE)" location: "JS frame :: resource://qbrt/modules/Runtime.jsm :: getOuterWindowID :: line 176" data: no]

Progress..?

benfrancis commented 5 years ago

Note: The above is the error I get when trying to run my own application with the qbrt runtime with qbrt run ./

If I try to run the eggtimer example as in the STR at the top of this issue (qbrt run https://eggtimer.org/), a blank window is opened but I see a different error on the command line:

JavaScript error: chrome://global/content/elements/browser-custom-element.js, line 874: TypeError: aParams is null

cr commented 5 years ago

Thunderbird apparently had the same problem and they solved it by "providing their own little generateQI implementation", which @cr didn't seem to like.

There wasn't a need to develop a like or dislike while Firefox still has ChromeUtils.generateQI() to use instead, and it works well for TLS Canary's intents and purposes.

cr commented 5 years ago

Progress..?

I just have the vague understanding of what's going on that .generateQI() is used to call C++ functions from JS, but whatever C++ object you're trying to query here for may not be supporting generating the requested interfaces. Perhaps you can look for an alternate that gets you what you need and also supports ChromeUtils.generateQI()?

cr commented 5 years ago

Any calls on top of .generateQI() fall through to respective C++ methods through IDL, so I'd start looking at the associated IDL specs. For example:

window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils).outerWindowID;

should first go through https://searchfox.org/mozilla-central/source/xpcom/base/nsIInterfaceRequestor.idl , which defines a .getInterface() method (as throwing NSNOINTERFACE on error), and also https://searchfox.org/mozilla-central/source/dom/interfaces/base/nsIDOMWindowUtils.idl supports the .outerWindowID_ attribute. So one may have to check argument types, but the error is obviously elsewhere:

I think the actual call failing is .getInterface(Ci.nsIDOMWindowUtils), unable to instantiate the nsIDOMWindowUtils interface for the particular object passed to .getOuterWindowID(). The code of Runtime.js a bit hard to follow, so it's hard to say what objects are passed in as target at https://github.com/mozilla/qbrt/blob/43d1b4a08c54c8003f9510da9edb2ac6fdd385f5/modules/Runtime.jsm#L79 . But whatever they are, they might not all be window like objects?

Another thing that has sometimes mended things was importing the right modules. The only other code I could find querying Ci.nsDOMWindowUtils is https://searchfox.org/mozilla-central/source/dom/canvas/test/webgl-conf/checkout/js/js-test-pre.js#730 . Perhaps the webgl-conf test harness makes some magic imports before that code is run?

Anyway, just a few pointers and loose threads. I wish I could help you more to the point.

benfrancis commented 5 years ago

Thanks for the pointers @cr!

Whilst I haven't got any further trying to fix that bug, I have realised that this broken code is part of the openDevTools() method in Runtime.jsm. If I don't try to open devtools in my application then qbrt will actually launch the application successfully. So this seems to be a recurrence of #132, where @mykmelez warned breakage with devtools was likely to happen again.

So replacing instances of XPCOMUtils.generateQI() with ChromeUtils.generateQI() does actually fix the bug reported in this issue for custom applications and qbrt can be started successfully.

The remaining error when trying to launch the example egg timer app appears to be related to the loadURI() method of the <browser> element in the default default Shell.js. Specifically, https://github.com/mozilla/qbrt/blob/master/shell/shell.js#L106 is trying to do:

browser.loadURI(url, null, null);

which worked previously, but for some reason now returns TypeError: aParams is null

From the docs and source code I haven't been able to figure out why this no longer works.

I'd also really like to get devtools working again!

benfrancis commented 5 years ago

Looks like loadURI() now expects an object as its second argument and requires that triggeringPrincipal be set.

See https://bugzilla.mozilla.org/show_bug.cgi?id=1513241#c35