SG-33297 Fix race condition on the login UX#1095
SG-33297 Fix race condition on the login UX#1095carlos-villavicencio-adsk wants to merge 2 commits intomasterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1095 +/- ##
=======================================
Coverage 79.43% 79.43%
=======================================
Files 198 198
Lines 20749 20750 +1
=======================================
+ Hits 16482 16483 +1
Misses 4267 4267
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Fixes an event-loop timing race in LoginDialog where the dialog could initially render the legacy 3-field credentials UI before the background site-info query’s QThread.finished signal was dispatched, causing incorrect UI selection for Identity/SSO sites (especially on slower/Windows systems).
Changes:
- Call
_toggle_web()synchronously inLoginDialog.__init__after the background querywait()returns, so the initial UI mode is set before the dialog is shown. - Add a regression test that asserts
method_selectedis notMETHOD_BASICbefore anyprocessEvents()call for an Autodesk Identity (“oxygen”) site.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
python/tank/authentication/login_dialog.py |
Invokes _toggle_web() immediately after the initial site-info query wait to avoid relying on queued cross-thread signal delivery. |
tests/authentication_tests/test_interactive_authentication.py |
Adds a regression test covering the pre-event-loop window where the wrong UI mode could be selected. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Summary
Fix a race condition in
LoginDialogthat caused the 3-fields credentials UI (host / login / password) to appear briefly — or permanently on slow / Windows systems — even when the target site uses Autodesk Identity or SSO.Root Cause
_toggle_web()was wired exclusively to theQThread.finishedsignal of the background site-info query task. Qt cross-thread signals are delivered through the event queue: the slot only runs once the event loop is spinning.Because the constructor calls
wait()to block until the thread finishes, then returns before the event loop has started, thefinishedsignal sits undelivered in the queue. The dialog opens with the hard-coded defaultMETHOD_BASIC(3-fields form). Only afterexec_()/show()kick the event loop does_toggle_webfire and correct the UI — far too late, and unreliable under timing pressure (Windows scheduler, cold cache, slow network).Fix
python/tank/authentication/login_dialog.pyCall
_toggle_web()synchronously immediately afterwait()returns, while still in the constructor. The site-info data is already populated at that point, so the dialog opens with the right UI state (web-login / ASL) before any pixels are painted.Test
The test constructs a LoginDialog for an oxygen (Autodesk Identity) site and asserts method_selected != METHOD_BASIC before any processEvents() call, directly reproducing the pre-fix failure window:
Without the fix this test fails (value is
METHOD_BASIC); with the fix it passes deterministically regardless of Qt event-loop timing.Notes
QThread.finished → _toggle_websignal connection is preserved for subsequent URL changes typed into the site field during an active session; only the initial synchronous call is new.SGTK_FORCE_STANDARD_LOGIN_DIALOGand all other existing overrides continue to work unchanged — the guard in _toggle_web handles them.wait()returning and the first event-loop tick.