[Qt-interest] UI Interaction Freezing when using QGraphicsView - How to Debug?
David Boosalis
david.boosalis at gmail.com
Sat Sep 19 14:08:15 CEST 2009
I ran your code on my Linux system which has an inferior cpu (AMD Athlon X2)
and a cheap built in graphics card on motherboard. Saw really flaky and
randon behavior. SOmetimes I saw what you saw, other times I started it and
it ran ok, albeit very slot
If I did not use the OpenGL widget it ran a lot better, but still very bad
for only 100 objects, then looked at Chips example n qt/demos which has
probable a 1000 items I think. I used there settings for QGraphicsView and
also switched to QGraphicsRectItem and things ran very smooth.
By the way, your code ran just as bad under Qt 4.6-tp1.
The code below ran very well. Maybe someone else can comment on how to tweek
Messa or OpenGL, but heck if it this sensitive to the openGL driver might as
well let Qt do the rendering and know it run adequately on any machine. I
hope someone can diagnose the opengl issue here
Regards
David
class BoxItem : public QGraphicsRectItem
{
public:
QRectF m_contentsRect;
QPen pen;
QBrush brush;
BoxItem(QGraphicsScene * scene, QGraphicsItem * parent) :
QGraphicsRectItem(0,0,500,500,parent)
{
setFlags(QGraphicsItem::ItemIsMovable);
setBrush(QColor(255,0,0,255));
pen.setWidthF(3);
pen.setColor(QColor(0,0,0,255));
}
};
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QGraphicsView *graphicsView = new QGraphicsView();
//graphicsView->setViewport(new
QGLWidget(QGLFormat(QGL::SampleBuffers)));
graphicsView->setCacheMode(QGraphicsView::CacheBackground);
graphicsView->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
graphicsView->setInteractive(true);
QGraphicsScene * scene = new QGraphicsScene();
scene->setBackgroundBrush(QColor(100,100,100));
graphicsView->setScene(scene);
scene->setSceneRect(0,0,800,600);
graphicsView->resize(800,600);
graphicsView->setWindowTitle("Test");
graphicsView->setRenderHint(QPainter::Antialiasing, false);
graphicsView->setDragMode(QGraphicsView::RubberBandDrag);
graphicsView->setOptimizationFlags(QGraphicsView::DontSavePainterState);
graphicsView->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
for(int i=0;i<100;i++)
{
BoxItem *x = new BoxItem(scene,0);
x->show();
x->setBrush(Qt::red);
x->setPos(qrand() % 800, qrand() % 600);
scene->addItem(x);
}
graphicsView->show();
return app.exec();
}
On Fri, Sep 18, 2009 at 5:24 PM, Josiah Bryan <jbryan at productiveconcepts.com
> wrote:
> Josiah Bryan wrote:
> ...
>
>> Its a rather extreem freeze - in fact, even the system mouse freezes
>> (under gdb, when not running in gdb, mouse doesn't freeze but unrelated apps
>> still do, like the charts in gkrellm.)
>>
> ...
>
> Alright, it took 4+ hours, but I narrowed it down to the attached test
> case.
>
> To reproduce:
>
> - Build and run
> - Attempt to drag any rectangle, even by a small amount.
> - Repeat until system becomes unresponsive (mouse freezes, other programs
> freeze.)
>
> On my system (specs below), the program freezes within 1 - 5 mouse
> interactions (drags.) This is with the both cores hovering around 5 - 10%
> load before mouse interaction following program launch. RAM is around 1.5GB
> free at time of tests, disk usage minimal (~64K/sec xfer load.) No other
> graphic intensive programs running - email, terminals, KWrite, etc. No other
> opengl programs (that I know of) - certainly no 3D programs.
>
> System info:
>
> Running with 4GB RAM on an Intel(R) Core(TM)2 Duo CPU, both cores running
> at 3.00GHz. Graphics card is a Quadro NVS 290 (PCIe card) with 256 MB RAM.
>
> X -version reports:
>
> X Window System Version 1.3.0
> Release Date: 19 April 2007
> X Protocol Version 11, Revision 0, Release 1.3
> Build Operating System: Fedora Core 7 Red Hat, Inc.
> Current Operating System: Linux josiah-desktop.pci.local 2.6.23.9-85.fc8 #1
> SMP Fri Dec 7 15:49:59 EST 2007 i686
> Build Date: 17 October 2007
> Build ID: xorg-x11-server 1.3.0.0-33.fc8
>
> NVidia control center reports under "OpenGL/GLX Information", heading
> "Server GLX Information", that the vendor is NVIDIA, version 1.4, with the
> following extensions:
>
> GLX_EXT_visual_info
> GLX_EXT_visual_rating
> GLX_SGIX_fbconfig
> GLX_SGIX_pbuffer
> GLX_SGI_video_sync
> GLX_SGI_swap_control
> GLX_EXT_texture_from_pixmap
> GLX_ARB_multisample
> GLX_NV_float_buffer
> GLX_ARB_fbconfig_float
> GLX_EXT_framebuffer_sRGB
>
>
> Tested on XP - not able to reproduce there. No other linux machines tested
> yet. Will test my home system this evening (CentOS 5.2, dual head, etc.)
>
> Anyone able to reproduce or offer tips on fixing? Anyone at trolltech able
> to comment?
>
> Thanks in advance.
> -josiah
>
>
>
> #include <QtGui/QApplication>
> #include <QGraphicsView>
> #include <QGraphicsItem>
> #include <QtOpenGL/QGLWidget>
>
> class BoxItem : public QGraphicsItem
> {
> public:
>
> QRectF m_contentsRect;
> QPen pen;
> QBrush brush;
>
> BoxItem(QGraphicsScene * scene, QGraphicsItem * parent) :
> QGraphicsItem(parent, scene),
> m_contentsRect(0,0,500,500), brush(QColor(255,0,0,255))
> {
> setFlags(QGraphicsItem::ItemIsMovable);
> pen.setWidthF(3);
> pen.setColor(QColor(0,0,0,255));
> }
>
> QRectF boundingRect() const
> {
> return m_contentsRect;
> }
>
> void paint(QPainter * painter, const QStyleOptionGraphicsItem *
> option, QWidget * widget)
> {
> painter->setPen(pen);
> painter->setBrush(brush);
> painter->drawRect(m_contentsRect);
> }
> };
>
> int main(int argc, char **argv)
> {
> QApplication app(argc, argv);
>
> QGraphicsView *graphicsView = new QGraphicsView();
> graphicsView->setViewport(new
> QGLWidget(QGLFormat(QGL::SampleBuffers)));
> graphicsView->setRenderHint( QPainter::Antialiasing, true );
>
> QGraphicsScene * scene = new QGraphicsScene();
>
> graphicsView->setScene(scene);
> scene->setSceneRect(0,0,800,600);
> graphicsView->resize(800,600);
> graphicsView->setWindowTitle("Test");
>
> for(int i=0;i<100;i++)
> {
> BoxItem *x = new BoxItem(scene,0);
> x->setPos(qrand() % 800, qrand() % 600);
> }
>
> graphicsView->show();
>
> return app.exec();
> }
>
>
> TEMPLATE = app
> TARGET =
> DEPENDPATH += .
> INCLUDEPATH += .
> QT += opengl
>
> # Input
> SOURCES += main.cpp
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090919/bb931a95/attachment.html
More information about the Qt-interest-old
mailing list