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

WebAssembly: Can't use multiple canvases/screens for multiple QQuickViews

    XMLWordPrintable

Details

    • WebAssembly

    Description

      I'm trying to display two QQuickView objects on two canvases/screens, like so:

       

      #include <QGuiApplication>
      #include <QQuickView>
      
      int main(int argc, char *argv[]){
      	QGuiApplication app(argc, argv);
      
      	const auto screens = app.screens();
      	if(screens.size() < 2){
      		qDebug() << "Expected at least 2 screens";
      		return 1;
      	}
      
      	for(auto & screen : screens){
      		qDebug() << screen;
      	}
      
      	QQuickView mainViewer;
      	mainViewer.setScreen(screens[0]);
      	mainViewer.setSource(QUrl(u"qrc:/wasm-multiwindow/main.qml"_qs));
      	mainViewer.setResizeMode(QQuickView::SizeRootObjectToView);
      
      
      	QQuickView secondViewer;
      	secondViewer.setScreen(screens[1]);
      	secondViewer.setSource(QUrl(u"qrc:/wasm-multiwindow/second.qml"_qs));
      	secondViewer.setResizeMode(QQuickView::SizeRootObjectToView);
      
      	mainViewer.show();
      	secondViewer.show();
      
      	return app.exec();
      }
      

      This code runs perfectly on Linux X11 target with 2 physical displays, but fails for webassembly:

      QRhiGles2: Failed to make context current. Expect bad things to happen.
      Failed to start frame
      

      If I set the same screen for both QQuickView objects, there's no error, but only one of them is visible of course.

      Also, I have no problem creating two QWidgets on two canvases:

      // this works
      #include <QApplication>
      #include <QWidget>
      
      
      int main(int argc, char *argv[]){
      	QApplication app(argc, argv);
      
      	const auto screens = app.screens();
      	if(screens.size() < 2){
      		qDebug() << "Expected at least 2 screens";
      		return 1;
      	}
      
      	QWidget w1;
      	w1.setScreen(screens[0]);
      	w1.show();
      
      	QWidget w2;
      	w2.setScreen(screens[1]);
      	w2.show();
      
      	return app.exec();
      }
      

      I attached a minimal example with a modified HTML file containing 2 canvases.

      I tested the code both in Firefox and Chromium.

      Attachments

        1. wasm-multiwindow.tar.gz
          5 kB
          Balázs Dura-Kovács

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              sorvig Morten Sørvig
              balping Balázs Dura-Kovács
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes