Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. Why crash on close when loading HTML using MapBox with QTWebengineview?
Forum Updated to NodeBB v4.3 + New Features

Why crash on close when loading HTML using MapBox with QTWebengineview?

Scheduled Pinned Locked Moved Unsolved QtWebEngine
3 Posts 2 Posters 471 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DGKim
    wrote on 12 Jan 2022, 03:47 last edited by
    #1

    A collision occurred while displaying a map of MapBox using QTWebEngineView.
    Previously, Google Maps and Ice Maps were displayed, but they worked well without problems.

    If you try to display MapBox's Map on QtWebenegineVIew, exit without any error logs the moment MapBox is about to display.

    <PyQt Code>

    import sys
    
    from PyQt5.QtWebEngineWidgets import *
    from PyQt5.QtWidgets import *
    from PyQt5.QtCore import *
    from PyQt5.QtGui import *
    
    
    class CustomWidget(QWidget):
        def __init__(self):
            super().__init__()
    
            self.__init_widget()
    
        def __init_widget(self):
            try:
                mapbox_html_path = "<HTML-PATH>"
    
                self.layout = QVBoxLayout()
                self.map_widget = QWebEngineView()
                self.map_widget.setAttribute(Qt.WA_DeleteOnClose)
                self.map_widget.load(QUrl.fromLocalFile(mapbox_html_path))
    
                self.dev_tool = QWebEngineView()
                self.map_widget.page().setDevToolsPage(self.dev_tool.page())
                self.dev_tool.show()
    
                self.layout.addWidget(self.map_widget)
    
                self.setLayout(self.layout)
            except Exception as e:
                print(e)
    
    
    if __name__ == '__main__':
        app = QApplication(sys.argv)
        app.setStyle(QStyleFactory.create("Fusion"))
        app.setAttribute(Qt.AA_EnableHighDpiScaling, True)
    
        custom_widget = CustomWidget()
        custom_widget.show()
    
        sys.exit(app.exec_())
    
    

    <MapBox HTML Code>

    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
        <meta charset="utf-8" />
        <script src='https://api.tiles.mapbox.com/mapbox-gl-js/v1.13.0/mapbox-gl.js'></script>
        <link href='https://api.tiles.mapbox.com/mapbox-gl-js/v1.13.0/mapbox-gl.css' rel='stylesheet' />
    </head>
    <body>
        <div id="map" style="position:relative;width:400px;height:400px;"></div>
        <script type='text/javascript'>
            var map = new mapboxgl.Map({
                style: {
                    version: 8,
                    sources: {
                        'raster-tiles': {
                            type: 'raster',
                            tiles: [
                                'http://ak.dynamic.t0.tiles.virtualearth.net/comp/ch/{quadkey}?mkt=ko&it=G,L&shading=hill&og=1679&n=z',
                                'http://ak.dynamic.t1.tiles.virtualearth.net/comp/ch/{quadkey}?mkt=ko&it=G,L&shading=hill&og=1679&n=z', 
                                'http://ak.dynamic.t2.tiles.virtualearth.net/comp/ch/{quadkey}?mkt=ko&it=G,L&shading=hill&og=1679&n=z',
                                'http://ak.dynamic.t3.tiles.virtualearth.net/comp/ch/{quadkey}?mkt=ko&it=G,L&shading=hill&og=1679&n=z'
                            ],
                        }
                    },
                    layers: [
                        {
                            id: 'simple-tiles',
                            type: 'raster',
                            source: 'raster-tiles',
                            minzoom: 0,
                            maxzoom: 22,
                        },
                    ],
                },
                center: [126.64846045343421, 37.36657719850406],
                zoom: 10,
                hash: true,
                container: 'map'
            });
        </script>
    </body>
    </html>
    

    How can you normally display MapBox's Map on QtWebEngineView?

    R 1 Reply Last reply 12 Jan 2022, 16:54
    0
    • D DGKim
      12 Jan 2022, 03:47

      A collision occurred while displaying a map of MapBox using QTWebEngineView.
      Previously, Google Maps and Ice Maps were displayed, but they worked well without problems.

      If you try to display MapBox's Map on QtWebenegineVIew, exit without any error logs the moment MapBox is about to display.

      <PyQt Code>

      import sys
      
      from PyQt5.QtWebEngineWidgets import *
      from PyQt5.QtWidgets import *
      from PyQt5.QtCore import *
      from PyQt5.QtGui import *
      
      
      class CustomWidget(QWidget):
          def __init__(self):
              super().__init__()
      
              self.__init_widget()
      
          def __init_widget(self):
              try:
                  mapbox_html_path = "<HTML-PATH>"
      
                  self.layout = QVBoxLayout()
                  self.map_widget = QWebEngineView()
                  self.map_widget.setAttribute(Qt.WA_DeleteOnClose)
                  self.map_widget.load(QUrl.fromLocalFile(mapbox_html_path))
      
                  self.dev_tool = QWebEngineView()
                  self.map_widget.page().setDevToolsPage(self.dev_tool.page())
                  self.dev_tool.show()
      
                  self.layout.addWidget(self.map_widget)
      
                  self.setLayout(self.layout)
              except Exception as e:
                  print(e)
      
      
      if __name__ == '__main__':
          app = QApplication(sys.argv)
          app.setStyle(QStyleFactory.create("Fusion"))
          app.setAttribute(Qt.AA_EnableHighDpiScaling, True)
      
          custom_widget = CustomWidget()
          custom_widget.show()
      
          sys.exit(app.exec_())
      
      

      <MapBox HTML Code>

      <!DOCTYPE html>
      <html>
      <head>
          <title></title>
          <meta charset="utf-8" />
          <script src='https://api.tiles.mapbox.com/mapbox-gl-js/v1.13.0/mapbox-gl.js'></script>
          <link href='https://api.tiles.mapbox.com/mapbox-gl-js/v1.13.0/mapbox-gl.css' rel='stylesheet' />
      </head>
      <body>
          <div id="map" style="position:relative;width:400px;height:400px;"></div>
          <script type='text/javascript'>
              var map = new mapboxgl.Map({
                  style: {
                      version: 8,
                      sources: {
                          'raster-tiles': {
                              type: 'raster',
                              tiles: [
                                  'http://ak.dynamic.t0.tiles.virtualearth.net/comp/ch/{quadkey}?mkt=ko&it=G,L&shading=hill&og=1679&n=z',
                                  'http://ak.dynamic.t1.tiles.virtualearth.net/comp/ch/{quadkey}?mkt=ko&it=G,L&shading=hill&og=1679&n=z', 
                                  'http://ak.dynamic.t2.tiles.virtualearth.net/comp/ch/{quadkey}?mkt=ko&it=G,L&shading=hill&og=1679&n=z',
                                  'http://ak.dynamic.t3.tiles.virtualearth.net/comp/ch/{quadkey}?mkt=ko&it=G,L&shading=hill&og=1679&n=z'
                              ],
                          }
                      },
                      layers: [
                          {
                              id: 'simple-tiles',
                              type: 'raster',
                              source: 'raster-tiles',
                              minzoom: 0,
                              maxzoom: 22,
                          },
                      ],
                  },
                  center: [126.64846045343421, 37.36657719850406],
                  zoom: 10,
                  hash: true,
                  container: 'map'
              });
          </script>
      </body>
      </html>
      

      How can you normally display MapBox's Map on QtWebEngineView?

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 12 Jan 2022, 16:54 last edited by
      #2

      @DGKim
      since you try to display mapbox-gl i assume its an issue with your graphics stack.

      what platform?
      what qt platform plugin?
      whats the ouput of the wbeview for the url "chrome://gpu"

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      D 1 Reply Last reply 12 Jan 2022, 23:52
      0
      • R raven-worx
        12 Jan 2022, 16:54

        @DGKim
        since you try to display mapbox-gl i assume its an issue with your graphics stack.

        what platform?
        what qt platform plugin?
        whats the ouput of the wbeview for the url "chrome://gpu"

        D Offline
        D Offline
        DGKim
        wrote on 12 Jan 2022, 23:52 last edited by
        #3

        @raven-worx

        I Dont Understand "Qt Flatform"
        But, I Solved This Problem.

        The problem was solved by using setHtml without using setUrl.
        However, I am not sure why it was resolved.

        1 Reply Last reply
        0

        1/3

        12 Jan 2022, 03:47

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved