ID 436435 - Opening a project via Python on startup, then calling TrackItem.thumbnail will cause Hiero to hang indefinitely

Follow

Problem summary
Opening a project via Python on startup, then calling TrackItem.thumbnail will cause Hiero to hang indefintely.

Customer reported version
Hiero 10.5v5

Customer reported platform
Windows

Steps to reproduce

1) To start, you will need to create a .hrox project that has at least one sequence with one track, that has some track items on it.

2) Save the following Python code to your ~/.nuke/Python/Startup directory

import hiero
import nuke

project = hiero.core.openProject("/path/to/project.hrox")
sequence = list(filter(lambda s: s.name() == "Sequence 1", project.sequences()))[0]
track = list(filter(lambda t: t.name() == "Video 1", sequence.videoTracks()))[0]

for track_item in track.items():
    image = track_item.thumbnail(track_item.sourceIn())

3) Open Hiero and notice that it hangs when opening the project.

Expected behaviour
Hiero should either return the QImage object or if this cannot be accessed, Hiero should throw an error.

Actual behaviour
Calling TrackItem.thumbnail when opening a project via Python on startup will cause Hiero to freeze.

Workaround
Using a QTimer may work as it will delay when track_item.thumbnail() is called by 2 seconds:

import hiero
import nuke
from PySide2.QtCore import QTimer

project = hiero.core.openProject("/path/to/project.hrox")
sequence = list(filter(lambda s: s.name() == "Sequence 1", project.sequences()))[0]
track = list(filter(lambda t: t.name() == "Video 1", sequence.videoTracks()))[0]

for track_item in track.items():
    def setImage():
        image = track_item.thumbnail(track_item.sourceIn())
        nuke.tprint(image) #just to show that the QImage object has been returned

    QTimer.singleShot(2000, lambda: setImage())

However, depending on the size of your project, the amount of time needed for the delay may vary.

Reproduced by support
This bug has been reproduced in:
Hiero 12.1v2 - Windows 10 - macOS 10.13 (High Sierra) - CentOS 7
Hiero 11.0v1 - Windows 10
Hiero 10.0v1 - Windows 10
Nuke Studio 9.0v1 - Windows 10 - macOS 10.13 (High Sierra)

Unable to reproduce bug in:
Guidance: List version/s you are unable to reproduce the bug in.
DELETE ENTIRE SECTION IF NOT RELEVANT

Earliest version tested
Nuke Studio 9.0v1
- This issue appears to be in all versions of the product

    We're sorry to hear that

    Please tell us why