[Development] Infinite loop in QML ShaderEffect polish()

Alberto Mardegan mardy at users.sourceforge.net
Thu Feb 16 15:25:58 CET 2023

Hi all!
    I've recently bumped into an issue on AuroraOS (a fork of 
SailfishOS), where as soon as an application window gets created, the 
output gets filled with logs similar to these, and the application gets 

[W] unknown:230 - qrc:/Sailfish/Silica/private/TabBar.qml:230:5: QML 
OpacityRampEffect: possible QQuickItem::polish() loop
[W] unknown:230 - qrc:/Sailfish/Silica/private/TabBar.qml:230:5: QML 
OpacityRampEffect: OpacityRampEffect called polish() inside 
updatePolish() of OpacityRampEffect

OpacityRampEffect is a ShaderEffect, and, in fact, while debugging I've 
reproduced the same issue with a pure QtQuick ShaderEffect. The warnings 
appear even if the ShaderEffect is unused (that is, no source is 
connected to it): it looks like instantiating it is enough to get the 
application stuck. The "live" and "recursive" properties have no effect 
on this.

The way I've fixed it (apparently, with no ill side effects) is this:

--- a/src/quick/items/qquickgenericshadereffect.cpp
+++ b/src/quick/items/qquickgenericshadereffect.cpp
@@ -332,7 +332,7 @@ void QQuickGenericShaderEffect::maybeUpdateShaders()
           // scenegraph ready. Schedule the polish to try again later. 
In case #2
           // the backend probably does not have shadereffect support so 
there is
           // nothing to do for us here.
-        if (!m_item->window() || 
+        if (!m_item->window())

That is, removing the check on isSceneGraphInitialized() and only queue 
a polish if the window has not been set yet. I noticed that the same 
logic is followed on the OpenGL implementation 
(QQuickOpenGLShaderEffect), but the whole logic behind this is not clear 
to me, so that's why I'm writing here. It indeed looks unlikely that 
this is a bug, otherwise it would have broken a lot of other setups as well.

Could there be something wrong in our QPA plugin (which is for the 99% 
the same as https://github.com/mer-hybris/qt5-qpa-hwcomposer-plugin)?
We are also using a scenegraph plugin, but I verified that even with it 
being removed, the issue presents itself.

For the record, this is on Qt 5.15.


http://www.mardy.it - Geek in un lingua international

More information about the Development mailing list