Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race condition/deadlock between Natron::SplashScreen and PyModalDialog created in onProjectCreated callback #487

Closed
philomory opened this issue May 5, 2020 · 6 comments

Comments

@philomory
Copy link

philomory commented May 5, 2020

Problem

I've written an onProjectCreated callback that prompts for certain information needed when setting up a new project in our environment (you can always click 'cancel' if you want a bare Natron project instead). It prompts for this information using a PyModalDialog.

However, there seems to be a race-condition/deadlock between PyModalDialog and Natron::SplashScreen. When my callback exec_()s the modal dialog, all other processing stops until the dialog completes, as expected. Unfortunately, this happens while the Natron splash screen is still displayed, showing the "Checking if updates are available" message. The modal dialog is behind the splash screen, and can't be interacted with; the splash screen, meanwhile, will not proceed past 'Checking if updates are available' while the modal dialog is open. The deadlock can be broken by pressing the Escape key to cancel the dialog, but then you don't get to actually use the dialog.

Expected behavior: Any one of the following:

  • Splash screen (and related background processes) should proceed while modal dialog is open
  • onProjectCreated callback should not be processed until after splash screen (and related background processing) is completed.
  • Modal dialog should appear appear in front of splash screen, rather than behind it.

It's worth noting that the "An auto-saved project was found with no associated project file" modal dialog waits patiently for the splash-screen to close before it is displayed; this is probably a good model to follow for the onProjectCreated callback as well.

Actual behavior: Modal dialog appears behind splash screen, preventing the splash screen from closing.

Steps to Reproduce

  1. Set up the following in initGui.py:
    from NatronGui import *
    
    def onProjectCreated(app):
      dialog = app.createModalDialog()
      dialog.setWindowTitle('Uh oh!')
      dialog.exec_()
    
    natron.setOnProjectCreatedCallback('onProjectCreated')
    
  2. Launch Natron
  3. Observe apparent deadlock

Versions

  • Natron version/commit: 2.3.15 Snapshot (RC17)
  • OS version: Windows 10
@philomory philomory changed the title Race condition/deadlock between Natron::SplashScreen and PyModelDialog created in onProjectCreated callback Race condition/deadlock between Natron::SplashScreen and PyModalDialog created in onProjectCreated callback May 5, 2020
@philomory
Copy link
Author

Looking at the source code for "autosaved project" modal, it appears that if said modal needs to be displayed, the Application doesn't wait for the splash screen to close, it actually proactively hides it. That being the case, a functional (though inelegant) workaround for the moment is:

from NatronGui import *
from PySide import QtGui

from NatronGui import *

def hideSplashScreen():
  for top in QtGui.qApp.topLevelWidgets():
    if top.isWindow() and not top.isHidden() and (top.windowFlags() & QtCore.Qt.FramelessWindowHint):
      top.hide()

def onProjectCreated(app):
  dialog = app.createModalDialog()
  dialog.setWindowTitle('Uh oh!')
  hideSplashScreen()
  dialog.exec_()

natron.setOnProjectCreatedCallback('onProjectCreated')

@devernay
Copy link
Member

I think PyModalDialog::PyModalDialog() is missing appPTR->hideSplashScreen(); at the beginning.

devernay added a commit that referenced this issue May 12, 2020
@devernay devernay added this to the 2.3 milestone May 12, 2020
@devernay
Copy link
Member

It was not deadlocking on macOS, so I am unable to say if this is fixed.
Maybe we'll soon get a new build from @rodlie for Windows.

@rodlie
Copy link
Contributor

rodlie commented May 12, 2020

Should have a new build uploaded within an hour.

@devernay
Copy link
Member

@philomory can you please test and report?

@philomory
Copy link
Author

@devernay @rodlie The new build appears to have resolved the issue, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants