fix: prevent duplicate Simple Browser panels when command triggered rapidly#298545
fix: prevent duplicate Simple Browser panels when command triggered rapidly#298545emmaeng700 wants to merge 3 commits intomicrosoft:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Prevents multiple Simple Browser webview panels from being created when SimpleBrowserManager.show() is triggered in quick succession, by adding an _opening guard around panel creation.
Changes:
- Add an
_openingboolean to guard against re-entrant/concurrentshow()calls. - Wrap
SimpleBrowserView.create(...)intry/finallyto reliably reset_opening.
| if (this._opening) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
When _opening is true, show() returns without applying the requested inputUri/options. If two callers race with different URLs or view columns, the later request is silently dropped and the created panel will show the first URL. Consider storing the latest pending {url, options} while opening and applying it after the view is created (or awaiting a shared “opening” promise and then calling .show(...)).
| if (this._opening) { | ||
| return; | ||
| } | ||
| this._opening = true; | ||
| try { | ||
| const view = SimpleBrowserView.create(this.extensionUri, url, options); | ||
| this.registerWebviewListeners(view); | ||
|
|
||
| this._activeView = view; | ||
| } finally { | ||
| this._opening = false; | ||
| } |
There was a problem hiding this comment.
This guard only prevents duplicate panels from concurrent show() calls. If a session restore (restore(...)) happens after a show() has already created a new panel (a plausible reload/activation race), restore(...) will still revive the old panel and leave it open because it does not dispose it when _activeView already exists. Consider explicitly resolving the show() vs restore() race by either disposing the restored panel when an active view already exists, or by making restore take precedence and closing/reusing the newly created panel.
- Replace boolean _opening guard with _pendingShow that stores the latest requested URL/options, so concurrent callers don't silently lose requests - After panel creation, apply the latest pending URL if it differs from the initial one - In restore(), dispose the restored panel if an active view already exists to prevent duplicate panels from show()/restore() races
|
@microsoft-github-policy-service agree |
|
@emmaeng700 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
|
@microsoft-github-policy-service agree |
Adds an _opening boolean guard to SimpleBrowserManager.show() so that concurrent invocations cannot create multiple webview panels simultaneously. Fixes #182795