Skip to content

Commit

Permalink
resume screenshot capture after onDidTerminateDebugSession
Browse files Browse the repository at this point in the history
  • Loading branch information
triwav committed Mar 1, 2024
1 parent ac68702 commit 0692b1b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export class Extension {
if (config.remoteControlMode?.deactivateOnSessionEnd) {
void this.remoteControlManager.setRemoteControlMode(false, 'launch');
}
this.webviewViewProviderManager.onDidTerminateDebugSession(e);
}
this.diagnosticManager.clear();
});
Expand Down
6 changes: 6 additions & 0 deletions src/managers/WebviewViewProviderManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ export class WebviewViewProviderManager {
}
}

public onDidTerminateDebugSession(e: vscode.DebugSession) {
for (const webview of this.webviewViews) {
webview.provider.onDidTerminateDebugSession(e);
}
}

// Notification from extension
public onChannelPublishedEvent(e: ChannelPublishedEvent) {
const config = e.body.launchConfiguration as BrightScriptLaunchConfiguration;
Expand Down
6 changes: 5 additions & 1 deletion src/viewProviders/BaseWebviewViewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ export abstract class BaseWebviewViewProvider implements vscode.WebviewViewProvi
}

public onDidStartDebugSession(e: vscode.DebugSession) {
// Can be overwritten in a child to notify on channel publish
// Can be overwritten in a child to notify on debug session start
}

public onDidTerminateDebugSession(e: vscode.DebugSession) {
// Can be overwritten in a child to notify on debug session end
}

public onChannelPublishedEvent(e: ChannelPublishedEvent) {
Expand Down
13 changes: 12 additions & 1 deletion src/viewProviders/RokuDeviceViewViewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export class RokuDeviceViewViewProvider extends BaseRdbViewProvider {
public readonly id = ViewProviderId.rokuDeviceView;

private temporarilyDisableScreenshotCapture = false;
private resumeScreenshotCapture: () => void | undefined;

constructor(context: vscode.ExtensionContext, dependencies) {
super(context, dependencies);
Expand All @@ -28,7 +29,10 @@ export class RokuDeviceViewViewProvider extends BaseRdbViewProvider {
try {
if (this.temporarilyDisableScreenshotCapture) {
// Sometimes we need to temporarily stop screenshot capture as it can prevent successful package deployment to the device
return;
// Originally was just returning true here but now we just pause until we resume capturing
await new Promise<void>((resolve) => {
this.resumeScreenshotCapture = resolve;
});
}
const result = await this.dependencies.rtaManager.device.getScreenshot();
this.postOrQueueMessage({
Expand All @@ -54,7 +58,14 @@ export class RokuDeviceViewViewProvider extends BaseRdbViewProvider {
this.temporarilyDisableScreenshotCapture = true;
}

public onDidTerminateDebugSession(e: vscode.DebugSession) {
// In case we failed to start debugging we want to allow screenshots again
this.temporarilyDisableScreenshotCapture = false;
this.resumeScreenshotCapture?.();
}

public onChannelPublishedEvent(e: ChannelPublishedEvent) {
this.temporarilyDisableScreenshotCapture = false;
this.resumeScreenshotCapture?.();
}
}

0 comments on commit 0692b1b

Please sign in to comment.