Nuke 12.x crash on tk init

Hello everyone,

I have the problem that Nuke 12.1 and 12.2 crashes during the Toolkit initialisation on 30% of my workstations. Even with identical systems.

Environment:

Windows 10 
gtx2070 or gtx1080
Nuke 12.1 or 12.2
TK: Core and apps all latest.

This are the last outputs before the crash. No other errors or warnigs in debug mode logs:

tk-nuke.log:

2020-09-30 12:28:16,355 [4132 DEBUG sgtk.env.project.tk-nuke.tk-multi-workfiles2] BackgroundTaskManager [Main task manager] destroyed

Terminal output:

None
QThread: Destroyed while thread is still running

Does anyone have an idea?

Thanks and greetings

Jonas

2 Likes

Hi Jonas,

Not sure if this is at all related to your problem but we had some issues a couple of months back and was then later fixed in an updated version of the tk-nuke engine.

But until that fix was included in the engine we could set this env variable as a workaround:
SHOTGUN_SKIP_QTWEBENGINEWIDGETS_IMPORT=1

Are you on the latest version of the nuke engine as well?

As I mentioned this may not be related to your problem at all but could be worth a try!

All best,
Jonas

2 Likes

I should mention that our issue also prevented us from launching Nuke.

2 Likes

@jonas.lindfors thanks for your reply.

I tried that. I set this in the bootstrap.py hook. But with no effect.

Core, engines and apps are all on the latest releases.

name: tk-nuke
version: v0.12.7

greetings

Jonas

2 Likes

Hi Jonas,

we are currently investigating an issue with debug logging in Nuke where Nuke can crash if Nuke’s script editor is open.

Our current workaround it to turn off debug logging. Do you have it enabled on systems where it crashes? If yes, can you try turning off debug logging and see if the issue remains?

Cheers,
Francis

2 Likes

No different with or with out the debug mode.
In 1 of 20 startups via the tank.bat launch_nuke nuke does not crash, via Shotgun Desktop allways. But maybe that is a coincidence.

1 Like

Thanks for the info.

I think we’ll probably need to see your tk-nuke log file and also have access to your config to try to reproduce the issue on our side.

Can you create a support ticket with the log file and your zipped config folder attached to it?

Cheers,
Francis

2 Likes

Thanks @mathurf, I’ll do that.

1 Like

Was this at all solved?

We are running into similar issues with the following error:

QThread: Destroyed while thread is still running

We’re still running into this issue. Nuke 12.x crashing with:
QThread: Destroyed while thread is still running

It normally happens when using the tk-multi-workfiles2 app. It seems worse in our sites that have a higher latency to SG servers.

I’m suspecting that the engine is restarting as part of the callback and destroying a thread without shutting it down properly.

2 Likes

We are running into the same issues and I can corroborate it seems related to the Workfiles app (which we have running on Startup).

@Ricardo_Musch I think we might have tracked down the issue on our side. It was an app with a background task manager that wasn’t behaving nicely. Every time the file was saved it triggered an engine reload. There was a task manager that wasn’t shut down correctly so sometimes this caused a race condition that meant that the threads weren’t properly shut down before the QObject that owned the task manger got destroyed.

To fix the issue I’ve run deleteLater() on my task manager after calling shutting down. I’ve also forked the tk-nuke engine to only reload if the context actually changes (as I don’t see any reason to reload on every CTRL-S!). Note quite sure if that’s fixed the issue or not, but seems to have reduced crashing.

2 Likes

Awesome, yeah we think it may be based on a plugin or something too.

Are you able to share your fix for tk-nuke?

Still working out mechanics of submitting pull requests at my company but here’s a diff of what I did:

diff --git a/python/tk_nuke/__init__.py b/python/tk_nuke/__init__.py
index 1aec27e..c26d91e 100644
--- a/python/tk_nuke/__init__.py
+++ b/python/tk_nuke/__init__.py
@@ -99,13 +99,15 @@ def __engine_refresh(new_context):
     If an engine is already started then we just need to change context,
     else we need to start the engine.
     """
-
     engine_name = os.environ.get("TANK_NUKE_ENGINE_INIT_NAME")
 
     curr_engine = sgtk.platform.current_engine()
     if curr_engine:
-        # If we already have an engine, we can just tell it to change contexts
-        curr_engine.change_context(new_context)
+        if curr_engine.context != new_context: # Only run if we're changing the context.
+            # If we already have an engine, we can just tell it to change contexts
+            curr_engine.change_context(new_context)
+        else:
+            logger.info('Skipping context change as the new context is the same as the old')
     else:
         # try to create new engine
         try:
1 Like

@Ricardo_Musch we’ve just noticed that the above fix breaks the shotgun load when picking up someone else’s published script (it disables the toolkit). I wouldn’t recommend using it :wink:

1 Like

Hi everyone!

Now I am getting in line with the QThread: Destroyed while thread is still running error with the latest updates in SGTK. Nuke 12 and 14 are crashing 9 out of 10 times when I try to open them. I am very certain it is related to the workfiles2 app, because when I disable “launch_on_startup” everything works fine again. It feels like the workfiles app runs some threads to capture information and then kills the main thread in the process.
For the record: I do not have debug logging enabled, nor the script editor visible.
I am using:
tk-core: v0.21.2
tk-nuke: v0.15.1
tk-multi-workfiles2: v0.15.0

Does anybody have a solution to this? I’d rather not disable “launch_on_startup”, if I don’t have to.

Cheers,
Fabian

1 Like

I’ve seen this issue in the past but do not know how we solved it or if it solves itself. :confused:

1 Like