JS error in QtWebKit.QWebView - no error in IE11 or Chrome/Win

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

JS error in QtWebKit.QWebView - no error in IE11 or Chrome/Win

Tom Chadwin
qgis2web's preview pane is a QWebView. OpenLayers 3.13.0 has just been released. I've tried upgrading qgis2web's OpenLayers to that version, but the preview stops working. I found instructions for how to redirect the QWebView's console output to the QGIS Python console. The (not very meaningful) error I am getting is:

WARNING:root:JS undefined:0
TypeError: 'undefined' is not a function

However, if I export instead of previewing, and open the file in IE11 or Chrome/Win, I get no error. If I revert qgis2web to OL3.12.1, it starts working again.

Can anyone help me fix this? I've filed an issue at:

https://github.com/tomchadwin/qgis2web/issues/176

Thanks

Tom
Reply | Threaded
Open this post in threaded view
|

Re: JS error in QtWebKit.QWebView - no error in IE11 or Chrome/Win

Matthias Kuhn 🌍
Hi Tom,

You can enable developer tools on a QWebView and then use the inspector
and interactive JS console for debugging. That's very handy.

Matthias

On 01/21/2016 04:22 PM, Tom Chadwin wrote:

> qgis2web's preview pane is a QWebView. OpenLayers 3.13.0 has just been
> released. I've tried upgrading qgis2web's OpenLayers to that version, but
> the preview stops working. I found instructions for how to redirect the
> QWebView's console output to the QGIS Python console. The (not very
> meaningful) error I am getting is:
>
> WARNING:root:JS undefined:0
> TypeError: 'undefined' is not a function
>
> However, if I export instead of previewing, and open the file in IE11 or
> Chrome/Win, I get no error. If I revert qgis2web to OL3.12.1, it starts
> working again.
>
> Can anyone help me fix this? I've filed an issue at:
>
> https://github.com/tomchadwin/qgis2web/issues/176
>
> Thanks
>
> Tom
>
>
>
> --
> View this message in context: http://osgeo-org.1560.x6.nabble.com/JS-error-in-QtWebKit-QWebView-no-error-in-IE11-or-Chrome-Win-tp5246541.html
> Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.
> _______________________________________________
> Qgis-developer mailing list
> [hidden email]
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
--
Matthias Kuhn
OPENGIS.ch - https://www.opengis.ch
Spatial • (Q)GIS • PostGIS • Open Source



_______________________________________________
Qgis-developer mailing list
[hidden email]
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: JS error in QtWebKit.QWebView - no error in IE11 or Chrome/Win

Tom Chadwin
Thanks, Matthias - that should be just what I need. First attempts to implement it result in a minidump, but I'll keep trying.
Reply | Threaded
Open this post in threaded view
|

Re: JS error in QtWebKit.QWebView - no error in IE11 or Chrome/Win

enricofer
Does it happens in all platforms?
I have a problem like this under windows 32bit but not under Ubuntu or other external browser.
Attached there is a simple html that throws exceptions loading external libraries (angular.js !?) under webkit on windows 32bit, but loads fine on other platforms.

Regards. Enrico Ferreguti

2016-01-21 16:59 GMT+01:00 Tom Chadwin <[hidden email]>:
Thanks, Matthias - that should be just what I need. First attempts to
implement it result in a minidump, but I'll keep trying.



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/JS-error-in-QtWebKit-QWebView-no-error-in-IE11-or-Chrome-Win-tp5246541p5246553.html
Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.
_______________________________________________
Qgis-developer mailing list
[hidden email]
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer


_______________________________________________
Qgis-developer mailing list
[hidden email]
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: JS error in QtWebKit.QWebView - no error in IE11 or Chrome/Win

enricofer
...sorry, the attachment.

2016-01-21 17:36 GMT+01:00 Enrico Ferreguti <[hidden email]>:
Does it happens in all platforms?
I have a problem like this under windows 32bit but not under Ubuntu or other external browser.
Attached there is a simple html that throws exceptions loading external libraries (angular.js !?) under webkit on windows 32bit, but loads fine on other platforms.

Regards. Enrico Ferreguti

2016-01-21 16:59 GMT+01:00 Tom Chadwin <[hidden email]>:
Thanks, Matthias - that should be just what I need. First attempts to
implement it result in a minidump, but I'll keep trying.



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/JS-error-in-QtWebKit-QWebView-no-error-in-IE11-or-Chrome-Win-tp5246541p5246553.html
Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.
_______________________________________________
Qgis-developer mailing list
[hidden email]
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer



_______________________________________________
Qgis-developer mailing list
[hidden email]
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer

browse.html (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: JS error in QtWebKit.QWebView - no error in IE11 or Chrome/Win

Tom Chadwin
OK, I've got that working (thanks again, Matthias), and I'm getting an error in OL3.13.0 itself, not in my JS. I'll update the qgis2web Github issue, and see if I can get some OL3 help from somewhere. For info, the error I get is:

ol-debug.js:48906
TypeError: 'undefined' is not a function (evaluating 'handler.bind(s)')

Enrico, I only have Win x64 at the moment, so I don't know if it's platform-specific. As I say, it's specific to OL3.13.0, not present in OL3.12.1.
Reply | Threaded
Open this post in threaded view
|

Re: JS error in QtWebKit.QWebView - no error in IE11 or Chrome/Win

Tom Chadwin
Reply | Threaded
Open this post in threaded view
|

Re: JS error in QtWebKit.QWebView - no error in IE11 or Chrome/Win

Tom Chadwin
Just to close this one off, this issue was caused by OL3.13.0 replacing goog.bind() with Function.bind() as part of their move to abandon legacy code and insist on ECMA-compliant clients. Presumably the Qt4 WebKit is not thus compliant. Solution is to use a polyfill. All the details are in the OL3 Github issue above. I'll try it tomorrow.
Reply | Threaded
Open this post in threaded view
|

Re: JS error in QtWebKit.QWebView - no error in IE11 or Chrome/Win

Tom Chadwin
The polyfill works.

Matthias, any idea how I make QtWebKit.QWebInspector available in the QGIS Qt Designer? I've included it by hand-editing my ui.py file, but pyuic4 will obviously overwrite that.
Reply | Threaded
Open this post in threaded view
|

Re: JS error in QtWebKit.QWebView - no error in IE11 or Chrome/Win

ginetto
I don't know how it will be with QWebView, but I suppose will be
similar cnahging slightly the api

this is my common web view configuration that allow inspect

        # set webView setting
        QtWebKit.QWebSettings.globalSettings().setAttribute(QtWebKit.QWebSettings.JavascriptEnabled,
True)
        QtWebKit.QWebSettings.globalSettings().setAttribute(QtWebKit.QWebSettings.DeveloperExtrasEnabled,
True)
        QtWebKit.QWebSettings.globalSettings().setAttribute(QtWebKit.QWebSettings.JavascriptCanAccessClipboard,
False)
        # next parameters can crash qgis if user use arrows after
clicked in the sliders of the webview
        # QtWebKit.QWebSettings.globalSettings().setAttribute(QtWebKit.QWebSettings.SpatialNavigationEnabled,
True)
        QtWebKit.QWebSettings.globalSettings().setAttribute(QtWebKit.QWebSettings.PrintElementBackgrounds,
True)
        QtWebKit.QWebSettings.globalSettings().setAttribute(QtWebKit.QWebSettings.OfflineStorageDatabaseEnabled,
False)
        QtWebKit.QWebSettings.globalSettings().setAttribute(QtWebKit.QWebSettings.LocalStorageEnabled,
False)
        #QtWebKit.QWebSettings.globalSettings().globalSettings().enablePersistentStorage(QtCore.QDir.tempPath())

cheers
Luigi Pirelli

**************************************************************************************************
* Boundless QGIS Support/Development: lpirelli AT boundlessgeo DOT com
* LinkedIn: https://www.linkedin.com/in/luigipirelli
* Stackexchange: http://gis.stackexchange.com/users/19667/luigi-pirelli
* GitHub: https://github.com/luipir
* Mastering QGIS:
https://www.packtpub.com/application-development/mastering-qgis
**************************************************************************************************


On 22 January 2016 at 13:41, Tom Chadwin <[hidden email]> wrote:

> The polyfill works.
>
> Matthias, any idea how I make QtWebKit.QWebInspector available in the QGIS
> Qt Designer? I've included it by hand-editing my ui.py file, but pyuic4 will
> obviously overwrite that.
>
>
>
> --
> View this message in context: http://osgeo-org.1560.x6.nabble.com/JS-error-in-QtWebKit-QWebView-no-error-in-IE11-or-Chrome-Win-tp5246541p5246733.html
> Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.
> _______________________________________________
> Qgis-developer mailing list
> [hidden email]
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
_______________________________________________
Qgis-developer mailing list
[hidden email]
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: JS error in QtWebKit.QWebView - no error in IE11 or Chrome/Win

Tom Chadwin
I've got this working largely as I want - I now have a devtools inspector in my plugin dialog which F12 toggles (download qgis2web master from Github to see it).

I would like to toggle the inspector automatically if there is a JS error in the QWebPage/QWebView. I imagine this is done by subclassing javaScriptConsoleMessage(). However, if I do this, the inspector stops working, and becomes blank. Is this because:

1. My subclassing only javaScriptConsoleMessage detaches the inspector from the web page?

2. My subclassing only javaScriptConsoleMessage removes QtWebKit.QWebSettings.DeveloperExtrasEnabled?

As you can tell from my probably ignorantly phrased questions, I'm a bit out of my comfort zone, as someone with very little OOP knowledge.
Reply | Threaded
Open this post in threaded view
|

Re: JS error in QtWebKit.QWebView - no error in IE11 or Chrome/Win

ginetto
no...it's a bug of the webview.. Idid the same problems with the
QTraffic plugi nand I solved. Let me find the code
Luigi Pirelli

**************************************************************************************************
* Boundless QGIS Support/Development: lpirelli AT boundlessgeo DOT com
* LinkedIn: https://www.linkedin.com/in/luigipirelli
* Stackexchange: http://gis.stackexchange.com/users/19667/luigi-pirelli
* GitHub: https://github.com/luipir
* Mastering QGIS:
https://www.packtpub.com/application-development/mastering-qgis
**************************************************************************************************


On 22 January 2016 at 18:14, Tom Chadwin <[hidden email]> wrote:

> I've got this working largely as I want - I now have a devtools inspector in
> my plugin dialog which F12 toggles (download qgis2web master from Github to
> see it).
>
> I would like to toggle the inspector automatically if there is a JS error in
> the QWebPage/QWebView. I imagine this is done by subclassing
> javaScriptConsoleMessage(). However, if I do this, the inspector stops
> working, and becomes blank. Is this because:
>
> 1. My subclassing only javaScriptConsoleMessage detaches the inspector from
> the web page?
>
> 2. My subclassing only javaScriptConsoleMessage removes
> QtWebKit.QWebSettings.DeveloperExtrasEnabled?
>
> As you can tell from my probably ignorantly phrased questions, I'm a bit out
> of my comfort zone, as someone with very little OOP knowledge.
>
>
>
> --
> View this message in context: http://osgeo-org.1560.x6.nabble.com/JS-error-in-QtWebKit-QWebView-no-error-in-IE11-or-Chrome-Win-tp5246541p5246792.html
> Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.
> _______________________________________________
> Qgis-developer mailing list
> [hidden email]
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
_______________________________________________
Qgis-developer mailing list
[hidden email]
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: JS error in QtWebKit.QWebView - no error in IE11 or Chrome/Win

ginetto
sorry... was another problems to avoid stop bye qt debugger

but could be a snippet useful in case of problems... I use
DebugWebPageinstead of directly the webPage.

about your problem... whou it be set as slot?

this is th esnippet that does not solve our problem but others

class DebugWebPage(QtWebKit.QWebPage):
    ''' custom webpage used to avoid interruption of messagebox by QT
during debugging
    '''
    def __init__(self, parent):
        super(DebugWebPage, self).__init__(parent)

    @QtCore.pyqtSlot()
    def shouldInterruptJavaScript(self):
        return False
Luigi Pirelli

**************************************************************************************************
* Boundless QGIS Support/Development: lpirelli AT boundlessgeo DOT com
* LinkedIn: https://www.linkedin.com/in/luigipirelli
* Stackexchange: http://gis.stackexchange.com/users/19667/luigi-pirelli
* GitHub: https://github.com/luipir
* Mastering QGIS:
https://www.packtpub.com/application-development/mastering-qgis
**************************************************************************************************


On 22 January 2016 at 20:58, Luigi Pirelli <[hidden email]> wrote:

> no...it's a bug of the webview.. Idid the same problems with the
> QTraffic plugi nand I solved. Let me find the code
> Luigi Pirelli
>
> **************************************************************************************************
> * Boundless QGIS Support/Development: lpirelli AT boundlessgeo DOT com
> * LinkedIn: https://www.linkedin.com/in/luigipirelli
> * Stackexchange: http://gis.stackexchange.com/users/19667/luigi-pirelli
> * GitHub: https://github.com/luipir
> * Mastering QGIS:
> https://www.packtpub.com/application-development/mastering-qgis
> **************************************************************************************************
>
>
> On 22 January 2016 at 18:14, Tom Chadwin <[hidden email]> wrote:
>> I've got this working largely as I want - I now have a devtools inspector in
>> my plugin dialog which F12 toggles (download qgis2web master from Github to
>> see it).
>>
>> I would like to toggle the inspector automatically if there is a JS error in
>> the QWebPage/QWebView. I imagine this is done by subclassing
>> javaScriptConsoleMessage(). However, if I do this, the inspector stops
>> working, and becomes blank. Is this because:
>>
>> 1. My subclassing only javaScriptConsoleMessage detaches the inspector from
>> the web page?
>>
>> 2. My subclassing only javaScriptConsoleMessage removes
>> QtWebKit.QWebSettings.DeveloperExtrasEnabled?
>>
>> As you can tell from my probably ignorantly phrased questions, I'm a bit out
>> of my comfort zone, as someone with very little OOP knowledge.
>>
>>
>>
>> --
>> View this message in context: http://osgeo-org.1560.x6.nabble.com/JS-error-in-QtWebKit-QWebView-no-error-in-IE11-or-Chrome-Win-tp5246541p5246792.html
>> Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.
>> _______________________________________________
>> Qgis-developer mailing list
>> [hidden email]
>> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
_______________________________________________
Qgis-developer mailing list
[hidden email]
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer