<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[SoundEffect: &quot;QSocketNotifier: Invalid socket ... disabling...&quot; floods the log and the app freezes (Qt 6.12, Linux)]]></title><description><![CDATA[<p dir="auto">Hi all,</p>
<p dir="auto">I'm running into a problem with QML <code>SoundEffect</code> and wondering if anyone has seen this before.</p>
<p dir="auto"><strong>What I'm doing</strong></p>
<p dir="auto">My game has two <code>SoundEffect</code> instances (one per player). Whenever something happens in the game<br />
(at most about every 800 ms per player), I play a different short WAV file like this:</p>
<pre><code class="language-qml">SoundEffect { id: effect }

function playSound(url) {
    effect.stop()
    effect.source = url   // a different file from the previous one
    effect.play()         // not waiting for status == SoundEffect.Ready
}
</code></pre>
<p dir="auto">The WAV files are short (0.5 to 1.4 s, 16 bit PCM, 44.1 kHz).</p>
<p dir="auto"><strong>The problem</strong></p>
<p dir="auto">After a few seconds to a minute, this suddenly appears:</p>
<pre><code>QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread
QSocketNotifier: Invalid socket 15 and type 'Read', disabling...
QSocketNotifier: Invalid socket 15 and type 'Read', disabling...
... (repeated endlessly, hundreds of MB of log)
</code></pre>
<p dir="auto">From then on, timers no longer fire and the app is basically frozen, so I have to kill it.<br />
(The first line doesn't always show up.)</p>
<p dir="auto">A few observations:</p>
<ul>
<li>It only happened with two instances. With one instance, I couldn't reproduce it.</li>
<li>It didn't happen when the sounds were always cut off quickly by the next <code>stop()</code> (e.g. every 200 ms).</li>
<li>Using one <code>SoundEffect</code> per file with a fixed <code>source</code> (only calling <code>play()</code>) made it worse.</li>
<li><code>MediaPlayer</code> + <code>AudioOutput</code> works fine, but I'd like to stick with <code>SoundEffect</code> because its low-latency playback is a better fit for a game.</li>
</ul>
<p dir="auto"><strong>Environment</strong></p>
<ul>
<li>Ubuntu 24.04, PipeWire 1.0.5, X11</li>
<li>Qt 6.12.0 (gcc_64, installed via Qt Creator, unmodified), FFmpeg backend</li>
</ul>
<p dir="auto"><strong>Questions</strong></p>
<ul>
<li>Is this a known issue?</li>
<li>Is my usage (changing <code>source</code> right after <code>stop()</code>, calling <code>play()</code> before <code>Ready</code>) okay?<br />
If not, what's the recommended way to play different short sounds in quick succession?</li>
</ul>
<p dir="auto">I have a small project that reproduces it and can share it if that helps.</p>
<p dir="auto">Thanks!</p>
]]></description><link>https://forum.qt.io/topic/165215/soundeffect-qsocketnotifier-invalid-socket-...-disabling...-floods-the-log-and-the-app-freezes-qt-6.12-linux</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 13:40:30 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/165215.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 26 Oct 2026 13:54:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to SoundEffect: &quot;QSocketNotifier: Invalid socket ... disabling...&quot; floods the log and the app freezes (Qt 6.12, Linux) on Thu, 05 Nov 2026 12:53:30 GMT]]></title><description><![CDATA[<p dir="auto">Thank you for taking the time to test this.</p>
<p dir="auto">My environment is Ubuntu 24.04.5 LTS, and I can confirm that the issue does not occur with Qt 6.8.3 either. (The application ran for more than five minutes without freezing.)</p>
<p dir="auto">In my environment, sound also works with Qt 6.12.0, but the application eventually freezes and produces a large number of error messages.</p>
<p dir="auto">The FFmpeg versions used by Qt Multimedia are the same in my environment as well:</p>
<ul>
<li><strong>Qt 6.8.3</strong>
<ul>
<li>Using Qt multimedia with FFmpeg version 7.1 LGPL version 2.1 or later</li>
</ul>
</li>
<li><strong>Qt 6.12.0</strong>
<ul>
<li>Using Qt multimedia with FFmpeg version 9.0.1 LGPL version 2.1 or later</li>
</ul>
</li>
</ul>
<p dir="auto">It's interesting that different issues seem to occur depending on the Ubuntu version.</p>
]]></description><link>https://forum.qt.io/post/840766</link><guid isPermaLink="true">https://forum.qt.io/post/840766</guid><dc:creator><![CDATA[kataoka]]></dc:creator><pubDate>Thu, 05 Nov 2026 12:53:30 GMT</pubDate></item><item><title><![CDATA[Reply to SoundEffect: &quot;QSocketNotifier: Invalid socket ... disabling...&quot; floods the log and the app freezes (Qt 6.12, Linux) on Wed, 04 Nov 2026 15:12:57 GMT]]></title><description><![CDATA[<p dir="auto">I had bookmarked this page so I could test it "just for fun" (and to be helpful), mostly because it seemed like something I could easily test. I don't currently have any projects that need to play <code>wav</code> files with QML <code>SoundEffect</code>, so the outcome is not of immediate impact to me but (again) this seemed easy to paste into a QML file and launch.</p>
<p dir="auto">So (after a week's delay 😅) that is what I have done.</p>
<p dir="auto">My OS is <code>Ubuntu 22.04.5 LTS jammy</code></p>
<p dir="auto">I generated the <code>wav</code> files as follows:</p>
<pre><code>sox -n -r 48000 -b 16 tone_1.wav synth 0.6 sin 440
sox -n -r 48000 -b 16 tone_2.wav synth 0.5 sin 240
</code></pre>
<p dir="auto">When I launched the code using <code>Qt_desktop/6.8.3/gcc_64/bin/qmlscene</code>, things seem to work pretty well. I cannot reproduce the reported issue.</p>
<p dir="auto">I then tried with both:</p>
<ul>
<li><code>Qt_desktop/6.12.0/gcc_64/bin/qmlscene</code> and also</li>
<li><code>Qt_desktop/6.12.0/gcc_64/bin/qml</code></li>
</ul>
<p dir="auto">In both of these <code>6.12.0</code> attempts, I hear no sound whatsoever! 🫤</p>
<p dir="auto">So I still cannot reproduce the reported issue, but I definitely see different outcomes between 6.8.3 and 6.12.0, which the behavior in 6.12.0 seeming to be worse. (But maybe there is some other dependency I am missing to use multimedia in 6.12.0 on Ubuntu 22.04?  .... but there wasn't any warning or error printed that would hint in that direction...)</p>
<p dir="auto">When I use 6.8.3 I see:</p>
<pre><code>qt.multimedia.ffmpeg: Using Qt multimedia with FFmpeg version 7.1 LGPL version 2.1 or later
</code></pre>
<p dir="auto">And with 6.12.0 I see:</p>
<pre><code>qt.multimedia.ffmpeg: Using Qt multimedia with FFmpeg version 9.0.1 LGPL version 2.1 or later
</code></pre>
]]></description><link>https://forum.qt.io/post/840760</link><guid isPermaLink="true">https://forum.qt.io/post/840760</guid><dc:creator><![CDATA[KH-219Design]]></dc:creator><pubDate>Wed, 04 Nov 2026 15:12:57 GMT</pubDate></item><item><title><![CDATA[Reply to SoundEffect: &quot;QSocketNotifier: Invalid socket ... disabling...&quot; floods the log and the app freezes (Qt 6.12, Linux) on Tue, 27 Oct 2026 13:29:27 GMT]]></title><description><![CDATA[<p dir="auto">Thanks!</p>
<p dir="auto">It's a single QML file with two <code>SoundEffect</code> instances that do <code>stop()</code> → change <code>source</code> → <code>play()</code> on a timer,<br />
the same way as in my game. No C++ or build step is needed.</p>
<p dir="auto"><strong>Setup</strong></p>
<pre><code>soundeffect_repro/
  Main.qml
  sounds/tone_1.wav
  sounds/tone_2.wav
</code></pre>
<p dir="auto">Sorry, the WAV files (<code>tone_1.wav</code> and <code>tone_2.wav</code>) can't be uploaded, so you'll need to prepare two short WAV files yourself.<br />
Two different short WAV files are needed. Mine are 16 bit PCM, stereo, 44.1 kHz sine waves of 0.5 s and 0.6 s.</p>
<p dir="auto"><strong>Run</strong></p>
<pre><code>&lt;Qt&gt;/6.12.0/gcc_64/bin/qml Main.qml 2&gt; err.txt
grep -m3 -n QSocketNotifier err.txt
</code></pre>
<p dir="auto">I ran it 5 times, and it reproduced every time, after about 3 to 30 s.</p>
<pre><code>13:QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread
14:QSocketNotifier: Invalid socket 60 and type 'Read', disabling...
15:QSocketNotifier: Invalid socket 60 and type 'Read', disabling...
</code></pre>
<p dir="auto">When it reproduces:</p>
<ul>
<li><code>err.txt</code> fills up with <code>QSocketNotifier: Invalid socket ...</code> lines.</li>
<li>The square in the window stops rotating, the play count stops increasing, and no more sound is played<br />
(see the screenshot below).</li>
</ul>
<p dir="auto"><strong>Note: once the issue starts, <code>err.txt</code> keeps growing by tens of MB per second.<br />
Please stop the app (Ctrl+C) soon after it reproduces, or the file will get huge.</strong></p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/3750a5da-8208-4821-91b0-d6bd3f2443e9.png" alt="Screenshot from 2026-10-27 21-51-34.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"><strong>Main.qml</strong></p>
<pre><code class="language-qml">pragma ComponentBehavior: Bound
import QtQuick
import QtMultimedia

Window {
    id: root

    readonly property int playInterval: 800    // ms between plays of each SoundEffect
    readonly property list&lt;url&gt; soundUrls: [
        Qt.resolvedUrl("sounds/tone_1.wav"),
        Qt.resolvedUrl("sounds/tone_2.wav")
    ]
    property int playCount: 0

    width: 360
    height: 120
    visible: true
    title: "SoundEffect repro"

    // Two SoundEffect instances, the second one starting half an interval later
    Repeater {
        model: 2

        delegate: Item {
            id: player

            required property int index
            property int nextSound: index   // index into soundUrls

            function playNext() {
                effect.stop()
                effect.source = root.soundUrls[player.nextSound]   // a different file from the previous play
                effect.play()                                      // without waiting for SoundEffect.Ready
                player.nextSound = (player.nextSound + 1) % root.soundUrls.length
                root.playCount++
                console.log("play " + root.playCount + " instance " + player.index + " "
                            + effect.source.toString().split("/").pop())
            }

            SoundEffect {
                id: effect

                onStatusChanged: {
                    if (status === SoundEffect.Error)
                        console.log("instance " + player.index + ": Error " + source)
                }
            }

            Timer {
                interval: player.index * root.playInterval / 2
                running: true
                onTriggered: {
                    player.playNext()
                    repeatTimer.start()
                }
            }

            Timer {
                id: repeatTimer
                interval: root.playInterval
                repeat: true
                onTriggered: player.playNext()
            }
        }
    }

    // Progress line every 10 s; it stops once the issue starts
    Timer {
        interval: 10000
        running: true
        repeat: true
        onTriggered: console.log("progress: plays=" + root.playCount)
    }

    // Shows whether the GUI thread is still alive
    Rectangle {
        x: 20
        y: 30
        width: 60
        height: 60
        color: "steelblue"
        RotationAnimation on rotation {
            from: 0
            to: 360
            duration: 2000
            loops: Animation.Infinite
        }
    }

    Text {
        x: 110
        y: 50
        text: "plays: " + root.playCount
    }
}
</code></pre>
<p dir="auto">Thanks again!</p>
]]></description><link>https://forum.qt.io/post/840612</link><guid isPermaLink="true">https://forum.qt.io/post/840612</guid><dc:creator><![CDATA[kataoka]]></dc:creator><pubDate>Tue, 27 Oct 2026 13:29:27 GMT</pubDate></item><item><title><![CDATA[Reply to SoundEffect: &quot;QSocketNotifier: Invalid socket ... disabling...&quot; floods the log and the app freezes (Qt 6.12, Linux) on Mon, 26 Oct 2026 21:06:13 GMT]]></title><description><![CDATA[<p dir="auto">Hi and welcome to devnet,</p>
<p dir="auto">Sharing that small project would be nice as it will allow other people to try to reproduce your issue.</p>
]]></description><link>https://forum.qt.io/post/840604</link><guid isPermaLink="true">https://forum.qt.io/post/840604</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Mon, 26 Oct 2026 21:06:13 GMT</pubDate></item></channel></rss>