My app is crashing probably NOT! Due to Loader
-
Hi.
My app is crashing during startup on Android phone, never on Desktop. What is more it is crashing very randomly, on some phones is works every time (Android 6.0) on some never (6.0.1, 5.0.1), on my old Samsung S3 Android 4.2.2 sometimes I compile and it works, sometimes not.
I suspect this is due to Loader which I added to have a SplashSccreen, according to this bug Object destroyed during incubation it happens when Loader is in acynchronous mode.
However, even when asynchronous:false is set app is crashing randomly.
Debuger shows that is has stopped in main.cpp on line: "engine.load(QUrl(QLatin1String("qrc:/main.qml")));"
with output:1 QVector<QPointer<QQuickItem>>::reallocData(int, int, QFlags<QArrayData::AllocationOption>) 0x53e89b2c 2 QVector<QPointer<QQuickItem>>::resize(int) 0x53e89c78 3 QQuickRepeater::regenerate() 0x53e88b42 4 QQuickRepeater::componentComplete() 0x53e8990e 5 QQmlObjectCreator::finalize(QQmlInstantiationInterrupt&) 0x53a3f42e 6 QQmlIncubatorPrivate::incubate(QQmlInstantiationInterrupt&) 0x53a08b48 7 QQmlEnginePrivate::incubate(QQmlIncubator&, QQmlContextData *) 0x53a08db2 8 QQmlComponent::create(QQmlIncubator&, QQmlContext *, QQmlContext *) 0x53a074ea 9 QQuickLoaderPrivate::_q_sourceLoaded() 0x53e8a908 10 QQuickLoaderPrivate::load() 0x53e8a96a 11 QQmlObjectCreator::finalize(QQmlInstantiationInterrupt&) 0x53a3f42e 12 QQmlComponentPrivate::complete(QQmlEnginePrivate *, QQmlComponentPrivate::ConstructionState *) 0x53a062ca 13 QQmlComponentPrivate::completeCreate() 0x53a06322 14 QQmlComponent::create(QQmlContext *) 0x53a0624e 15 QQmlApplicationEnginePrivate::finishLoad(QQmlComponent *) 0x53a3b57c 16 QQmlApplicationEnginePrivate::startLoad(QUrl const&, QByteArray const&, bool) 0x53a3b69c 17 QQmlApplicationEngine::load(QUrl const&) 0x53a3b72a 18 main main.cpp 60 0x546dc024 19 startMainMethod(void *) 0x543a2336 20 __thread_entry 0x4021c3ec 21 pthread_create 0x4021bad8 22 ??
I have my main.qml like this
import QtQuick 2.9 Item { signal qmlLoaded() Loader { id: mainWindowLoader active: false source: "qrc:/window.qml" asynchronous: false onLoaded: { item.visible = true; splashScreenLoader.item.visible = false; splashScreenLoader.source = ""; qmlLoaded() } } Loader { id: splashScreenLoader source: "qrc:/splashscreen.qml" onLoaded: { mainWindowLoader.active = true; } } }
So my question is, do you suspect it can be due to Loader and this bug?
Is there some more debug I can get? I mean there is no specific error
I'm using delegates for my ListView, maybe this is a problem ?
I will try to get rid of the loader and SplashScreen and see if it helps.
I'm using Qt 5.9.1 on Linux 64BitBest Regards
Marek -
Hi,
After getting rid of the Loader and half of my application I have found a problem - uninitialized variable in C++ model, this variable was a property and has been an input for PageIndicator (count: PictureModel.rows)
//C++ part class PictureModel : public QAbstractListModel { Q_OBJECT public: enum ItemRoles { IdRole = Qt::UserRole + 1, PicNameRole = Qt::UserRole + 2, PicAvailable = Qt::UserRole + 3, }; Q_PROPERTY(int rows MEMBER m_rows NOTIFY rowsChanged) .... //qml part ListView { id: plantPicView snapMode: ListView.SnapOneItem highlightRangeMode: ListView.StrictlyEnforceRange orientation: Qt.Horizontal width:(PictureModel.rows ? parent.width : 0) height:(PictureModel.rows ? 3*width/4 : 0) anchors.horizontalCenter: parent.horizontalCenter clip: true z:10 model: PictureModel delegate: PictureDelegate { z:11 source: pic_name_role } spacing: 0 } PageIndicator { id:pageIndicator anchors.top: plantPicView.bottom height: titleText.height/2 anchors.horizontalCenter: listViewRect.horizontalCenter currentIndex: plantPicView.currentIndex count: PictureModel.rows delegate: Rectangle { width: titleText.height/2 height: titleText.height/2 radius: width / 2 color: "#21be2b" opacity: index === plantPicView.currentIndex ? 0.95 : pressed ? 0.7 : 0.45 Behavior on opacity { OpacityAnimator { duration: 100 } } MouseArea { anchors.fill: parent onClicked: { plantPicView.currentIndex = index } } } }
But here comes really really important question:
Are there some techniques/tools that should show me this error, of which I don't know about, like QML profiling or something, maybe except: "Remember always initialize your variables" :)
All I could see running debugger in QtCreator was that something was resized/reallocated1 QVector<QPointer<QQuickItem>>::reallocData(int, int, QFlags<QArrayData::AllocationOption>) 0x53e89b2c 2 QVector<QPointer<QQuickItem>>::resize(int) 0x53e89c78 3 QQuickRepeater::regenerate() 0x53e88b42 4 QQuickRepeater::componentComplete() 0x53e8990e 5 QQmlObjectCreator::finalize(QQmlInstantiationInterrupt&) 0x53a3f42e 6 QQmlComponentPrivate::complete(QQmlEnginePrivate *, QQmlComponentPrivate::ConstructionState *) 0x53a062ca 7 QQmlComponentPrivate::completeCreate() 0x53a06322 8 QQmlComponent::create(QQmlContext *) 0x53a0624e 9 QQmlApplicationEnginePrivate::finishLoad(QQmlComponent *) 0x53a3b57c 10 QQmlApplicationEnginePrivate::startLoad(QUrl const&, QByteArray const&, bool) 0x53a3b69c 11 QQmlApplicationEngine::load(QUrl const&) 0x53a3b72a 12 main main.cpp 60 0x546dc024 13 startMainMethod(void *) 0x543a2336 14 __thread_entry 0x4021c3ec 15 pthread_create 0x4021bad8
Best Regards
Marek