Skip to content

Commit

Permalink
Trace for notebook editor markup warmup (#161516)
Browse files Browse the repository at this point in the history
  • Loading branch information
rebornix authored Sep 22, 2022
1 parent e426aaf commit d847171
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ import { EditorExtensionsRegistry } from 'vs/editor/browser/editorExtensions';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { NotebookPerfMarks } from 'vs/workbench/contrib/notebook/common/notebookPerformance';
import { BaseCellEditorOptions } from 'vs/workbench/contrib/notebook/browser/viewModel/cellEditorOptions';
import { ILogService } from 'vs/platform/log/common/log';

const $ = DOM.$;

Expand Down Expand Up @@ -255,6 +256,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
@INotebookExecutionService private readonly notebookExecutionService: INotebookExecutionService,
@INotebookExecutionStateService notebookExecutionStateService: INotebookExecutionStateService,
@IEditorProgressService private readonly editorProgressService: IEditorProgressService,
@ILogService private readonly logService: ILogService
) {
super();
this.isEmbedded = creationOptions.isEmbedded ?? false;
Expand Down Expand Up @@ -1481,12 +1483,15 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD

private async _warmupWithMarkdownRenderer(viewModel: NotebookViewModel, viewState: INotebookEditorViewState | undefined) {

this.logService.trace('NotebookEditorWidget.warmup', this.viewModel?.uri.toString());
await this._resolveWebview();
this.logService.trace('NotebookEditorWidget.warmup - webview resolved');

// make sure that the webview is not visible otherwise users will see pre-rendered markdown cells in wrong position as the list view doesn't have a correct `top` offset yet
this._webview!.element.style.visibility = 'hidden';
// warm up can take around 200ms to load markdown libraries, etc.
await this._warmupViewport(viewModel, viewState);
this.logService.trace('NotebookEditorWidget.warmup - viewport warmed up');

// todo@rebornix @mjbvz, is this too complicated?

Expand All @@ -1505,7 +1510,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
this._list.scrollTop = viewState?.scrollPosition?.top ?? 0;
this._debug('finish initial viewport warmup and view state restore.');
this._webview!.element.style.visibility = 'visible';

this.logService.trace('NotebookEditorWidget.warmup - list view model attached, set to visible');
}

private async _warmupViewport(viewModel: NotebookViewModel, viewState: INotebookEditorViewState | undefined) {
Expand Down

0 comments on commit d847171

Please sign in to comment.