Repository navigation
fix(vs): Marshal dispose to the UI thread - #24321
Conversation
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24321/wasm-skia-net9/index.html |
There was a problem hiding this comment.
🟡 Changes recommended
EntryPoint.Dispose() is now explicitly callable from any thread, but the _isDisposed guard remains non-atomic and can allow concurrent dispose execution.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR fixes Visual Studio extension teardown failures by ensuring disposal of UI-thread-affine COM objects is marshaled onto the VS main (UI) thread, preventing COMException during solution close.
Changes:
- Marshal
InfoBarFactory.Dispose()to the UI thread when invoked from a background thread. - Marshal
EntryPoint.Dispose()teardown to the UI thread viaDisposeCore()+JoinableTaskFactory.Run/SwitchToMainThreadAsync().
File summaries
| File | Description |
|---|---|
| src/Uno.UI.RemoteControl.VS/Notifications/InfoBar.cs | Updates InfoBarFactory.Dispose to switch to the main thread before closing/removing InfoBars. |
| src/Uno.UI.RemoteControl.VS/EntryPoint.cs | Wraps teardown in a UI-thread marshal and extracts COM-affine cleanup into DisposeCore(). |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24321/wasm-skia-net9/index.html |
morning4coffe-dev
left a comment
There was a problem hiding this comment.
Marshaling the entire COM-affine teardown with JoinableTaskFactory, with a UI-thread fast path, addresses the actual failure rather than merely removing ThrowIfNotOnUIThread. DisposeCore retains its thread guard, and InfoBarFactory's independently reachable disposal receives the same protection. The existing non-atomic disposed flag remains a separate concurrent-disposal hardening concern, not proof that this thread-affinity fix is wrong. This is Visual Studio threading, not microsoft-ui-xaml runtime behavior.
dr1rrb
left a comment
There was a problem hiding this comment.
Approving since this will not cause any issue, but not the best fix possible
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
|
@Mergifyio backport servicing/6.8 release/stable/6.7 |
✅ Backports have been createdDetails
|
…r-24321 fix(vs): Marshal dispose to the UI thread (backport #24321)
…6.7/pr-24321 fix(vs): Marshal dispose to the UI thread (backport #24321)
GitHub Issue: closes #24149
PR Type:
🐞 Bugfix
What changed? 🚀
Uno.UI.RemoteControl.VS.EntryPointcan be disposed from any thread — for example, the Studio VSIX (DevServerLauncher) disposes the reflection-loaded entry point from a thread-pool task while the solution is closing. The teardown, however, touches UI-thread-affine COM objects (DTEBuildEventsunsubscription,IVsInfoBar*cleanup, menu command disposal), which throwsCOMExceptionwhen invoked off the UI thread.Because
Disposewraps the teardown in atry/catchand_isDisposedis set up-front, the exception was swallowed and the teardown was silently aborted partway through:_unoMenuCommand,_appLaunchIdeBridge, and_appLaunchStateConsumerleaked, and open InfoBars were never removed.This PR marshals the teardown to the UI thread:
EntryPoint.Disposenow takes aThreadHelper.CheckAccess()fast path when already on the UI thread, and otherwise runs the teardown viaThreadHelper.JoinableTaskFactory.Run+SwitchToMainThreadAsync. The teardown body is extracted intoDisposeCore, which keepsThrowIfNotOnUIThreadas a guard. Marshaling once at theEntryPointlevel covers all child disposables.InfoBarFactory.Disposegets the same treatment (it is also reachable independently), replacing its formerThrowIfNotOnUIThreadhard requirement.PR Checklist ✅
Screenshots Compare Test Runresults — not applicable, VS tooling only.