Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Dynamically changes the Image source may lead to crash ?

Dynamically changes the Image source may lead to crash ?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 685 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Renaud G.R Offline
    Renaud G.R Offline
    Renaud G.
    wrote on last edited by
    #1

    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 ?

    Rolisteam: RPG virtual tabletop software in Qt: www.rolisteam.org : https://github.com/Rolisteam/rolisteam
    Github: https://github.com/obiwankennedy

    A 1 Reply Last reply
    0
    • Renaud G.R Renaud G.

      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 ?

      A Offline
      A Offline
      ambershark
      wrote on last edited by
      #2

      @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.

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved