wang-bin / QtAV

A cross-platform multimedia framework based on Qt and FFmpeg. 基于Qt和FFmpeg的跨平台高性能音视频播放框架. Recommand to use new sdk https://github.com/wang-bin/mdk-sdk
http://qtav.org
3.93k stars 1.5k forks source link

Crash with Qml StackView #798

Open Sylva1n opened 7 years ago

Sylva1n commented 7 years ago

Hi,

with Qt 5.7.0 and QtCreator 4.1.0, this minimal Qt project crashes (QtAVVideoBug). I tested it on MacOs, i0s and Android.

Download the project here: QtAVVideoBug.zip

Here comes its QML:

import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.1
import QtAV 1.7

ApplicationWindow {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    StackView {
        id: stackView
        anchors.fill: parent

        initialItem: Page {
            Button {
                text: qsTr("Watch Video")
                anchors.centerIn: parent
                onClicked: stackView.push(component_VideoPage)
            }
        }
    }

    Component {
        id: component_VideoPage
        Page {
            Video {
                id: video
                width: 640
                height: 480
                autoPlay: true
                source: "qrc:/big_buck_bunny.mp4"
            }
            Button {
                text: qsTr("< Back")
                anchors.centerIn: parent
                onClicked: {
                    video.stop()
                    video.source = ""
                    video.destroy()
                    stackView.pop()
                }
            }
        }
    }
}

I can't figure out if it comes from QtAV or Qml.

What is your opinion?

Thanks

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/40275743-crash-with-qml-stackview?utm_campaign=plugin&utm_content=tracker%2F307703&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F307703&utm_medium=issues&utm_source=github).
Sylva1n commented 7 years ago

The bug is fixed by adding this instruction in the main():

qputenv("QSG_RENDER_LOOP", "basic");

Anyway, it may alter the performance.

What do you think about it?

wang-bin commented 7 years ago

Try the latest code

gfremex commented 5 years ago

Crash also happens with Felgo.

When a Page with a Video component is pushed into NavigationStack (The page becomes the current page) the video file can be played well. But crash always happens when invoking navigationStack.pop() which means going back to the previous Page.

import QtQuick 2.0
import Felgo 3.0
import QtAV 1.7

Page {
    id: page

    property alias source: video.source

    Video {
        id: video
        autoPlay: true
        videoCodecPriority: ["HW", "FFmpeg"]

        width: dp(320)
        height: dp(240)

        onErrorChanged: console.log("onErrorChanged: " + error)
        onErrorStringChanged: console.log("onErrorStringChanged: " + errorString)
    }

    MouseArea {
        anchors.fill: parent
        onClicked: {
            video.stop()

            page.navigationStack.pop()
        }
    }
}

Versions:

Qt: 5.11.1 QtAV: 1.12.0 Felgo: 3.1.0 iPhoneOS.platform: iPhoneOS12.2.sdk

This workaround

qputenv("QSG_RENDER_LOOP", "basic");

also works on iOS as @Sylva1n mentioned.