Dynamically changes the Image source may lead to crash ?



  • Hello everyone !

    I would like your opinion about some strange crashes I experienced on embedded application.

    The application has many image items and the source of those items are depending on one value.
    When we are in manual, we display all manual images and when we change to automatic mode. Many image sources change to another image file.
    We experience some crashes when it change.

    Example:

    Image {
         source: isManual ? "../../manual/image_200.png" : "../../automatic/image_200.png"
    }
    Image {
         source: isManual ? "../../manual/image_201.png" : "../../automatic/image_201.png"
    }
    […]
    

    I compiled Qt in debug mode and found out the crashes occur inside this function: int QSGOpaqueTextureMaterial::compare(const QSGMaterial *o) const
    I put outputs message in Qt to show the path of image calling this method.
    It always used by Image item with the source changing according to parameter.

    My theory:
    As I understand, the cache system is full so it drops some images but at the same time, update requests are sent and requests are managed after the deletion of images. 
    The problem occurs on the embedded platform when the main thread has to manage heavy network communication.
    On regular computers (or/and without the network communication) it does not occur.

    I'm wondering if my idea is possible or am I completely wrong ?


  • Moderators

    @Renaud-G. It sounds feasible. What I would look at along those lines is your mainthread not getting a chance to handle all outstanding gui messages before things are changed/cleaned.

    Is it possible to move your network stuff to a different thread allowing your main thread's event queue to be a bit leaner?

    It's also possible that your original image's memory is cleaned up and when the compare() happens it is referencing memory that is gone.. What is the code on the line where it is crashing? This would probably be a bug in Qt though so it's a bit less likely.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.