WorldWideTelescope / wwt-web-client

The WorldWide Telescope web client lets you explore the universe in your browser.
https://worldwidetelescope.org/webclient/
MIT License
105 stars 35 forks source link

Issue when using WorldWideTelescope from Qt WebKit #173

Open astrofrog opened 6 years ago

astrofrog commented 6 years ago

I'm running into an issue where panning in a certain direction causes the following error:

INDEX_SIZE_ERR: DOM Exception 1: Index or size was negative, or greater than the allowed value. 0 undefined None

and after this any overlays (constellations etc) disappear and WWT is frozen:

wwt_webkit

This occurs when trying to use WWT from a Qt widget using QtWebKit. The script to reproduce the issue is:

from __future__ import absolute_import, division, print_function

from PyQt4.QtWebKit import QWebView, QWebPage
from PyQt4 import QtGui

WWT_HTML_FILE = 'wwt.html'

with open(WWT_HTML_FILE) as f:
    WWT_HTML = f.read()

class WWTQWebEnginePage(QWebPage):
    def javaScriptConsoleMessage(self, level=None, message=None,
                                 line_number=None, source_id=None):
        print(level, message, line_number, source_id)

if __name__ == "__main__":

    app = QtGui.QApplication([''])

    web = QWebView()
    page = WWTQWebEnginePage()
    page.setView(web)
    web.setPage(page)
    web.setHtml(WWT_HTML)

    web.show()

    app.exec_()

and the following should be placed in a file called wwt.html in the same directory:


<!DOCTYPE html >
<html style="height: 100%; padding: 0px; margin: 0px; background-color: #000000;">
  <head>

    <meta charset="utf-8" http-equiv="X-UA-Compatible" content="chrome=1, IE=edge"/>

    <title>Simple WWT Web Client</title>
    <script src="http://www.worldwidetelescope.org/scripts/wwtsdk.aspx"></script>
    <script src="https://code.jquery.com/jquery-1.8.3.min.js"></script>

    <script>

      var wwt;

      function initialize() {
        wwt = wwtlib.WWTControl.initControlParam("WWTCanvas", true);
        wwt.add_ready(wwtReady);
      }

      function wwtReady() {
        wwt.loadImageCollection('http://www.worldwidetelescope.org/wwtweb/catalog.aspx?W=surveys');
        sizeContent();
      }

      function sizeContent() {
        var newHeight = ($("html").height()) + "px";
        var newWidth = ($("html").width()) + "px";
        $("#WWTCanvas").css("height", newHeight);
        $("#WWTCanvas").css("width", newWidth);
      }

    </script>

  </head>

  <body onload="initialize()" style="margin: 0; padding: 0">
      <div id="WWTCanvas" style="width: 100; height: 100; border-style: none; border-width: 0px;"></div>
    </div>
  </body>
</html>

The reason we need this to work is for pywwt - even recent PyQt5 installations sometimes don't have WebEngine (which works fine). Is there any way to get this to work from the WWT side, or might the bug be on the WebKit side?