Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-54466

Crash in Canvas3D using threejs.js - when trying to render an 3D object

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.6.1
    • Canvas3D
    • None
    • Ubuntu 15.10

    Description

      I'm running Canvas3D inside a QQuickWidget - I also have this patch applied:
      https://codereview.qt-project.org/#/c/163864/

      Basically this is the JavaScript code that makes it crash:

              var loader = new THREE.JSONLoader();
              // load a resource
              loader.load(
                  // resource URL
                  'carmodel/car_model.js',
                  // Function when resource is loaded
                  function ( geometry, materials ) {
                      console.log("loaded :)")
                      var tmaterial = new THREE.MeshLambertMaterial({
                          map: THREE.ImageUtils.loadTexture('carmodel/gtare.png'),
                          colorAmbient: [0.480000026226044, 0.480000026226044, 0.480000026226044],
                          colorDiffuse: [0.480000026226044, 0.480000026226044, 0.480000026226044],
                          colorSpecular: [0.8999999761581421, 0.8999999761581421, 0.8999999761581421]
                      });
                      
                      car_model_mesh = new THREE.Mesh(
                          geometry,
                          tmaterial
                      );
                      
                      car_model_mesh.receiveShadow = true;
                      car_model_mesh.castShadow = true;
                      car_model_mesh.scale.set(0.024,0.024,0.024)
                      car_model_mesh.position.z = -0.425
                      // mesh.rotation.y = -Math.PI/5;
                      
                      
                      // var material = new THREE.MeshFaceMaterial( materials );
                      // var object = new THREE.Mesh( geometry, material );
                      scene.add( car_model_mesh );
                      // car_model_mesh = mesh
                  }
              );
      

      What I've seen so far digging into the sources of QtCanvas3D is that in renderjob.cpp:

      renderjob.cpp
              if (!m_renderer->usingQtContext()) {
                  oldContext = QOpenGLContext::currentContext();
                  oldSurface = oldContext->surface();
                  m_renderer->makeCanvasContextCurrent();
              }
      

      For some reason QOpenGLContext::currentContext() return NULL and that makes the line below oldContext->surface() to crash by a Segmentation fault.

      Attachments

        1. Qt-Backtrace_Canvas3D-crash.txt
          89 kB
          Benny Sjöstrand
        2. qt-stacktrace.txt
          21 kB
          Benny Sjöstrand

        Activity

          People

            e0348803 Miikka Heikkinen
            bennysj Benny Sjöstrand
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: