Skip to content

Commit de49b03

Browse files
committed
Use log service in TaskQueue
Fixes microsoft#242078
1 parent bc99eae commit de49b03

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/vs/editor/browser/gpu/atlas/textureAtlas.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export class TextureAtlas extends Disposable {
170170
throw new BugIndicatingError('Cannot warm atlas without color map');
171171
}
172172
this._warmUpTask.value?.clear();
173-
const taskQueue = this._warmUpTask.value = new IdleTaskQueue();
173+
const taskQueue = this._warmUpTask.value = this._instantiationService.createInstance(IdleTaskQueue);
174174
// Warm up using roughly the larger glyphs first to help optimize atlas allocation
175175
// A-Z
176176
for (let code = CharCode.A; code <= CharCode.Z; code++) {

src/vs/editor/browser/gpu/taskQueue.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
import { getActiveWindow } from '../../../base/browser/dom.js';
77
import { Disposable, toDisposable, type IDisposable } from '../../../base/common/lifecycle.js';
8+
import { IInstantiationService } from '../../../platform/instantiation/common/instantiation.js';
9+
import { ILogService } from '../../../platform/log/common/log.js';
810

911
/**
1012
* Copyright (c) 2022 The xterm.js authors. All rights reserved.
@@ -41,7 +43,9 @@ abstract class TaskQueue extends Disposable implements ITaskQueue {
4143
private _idleCallback?: number;
4244
private _i = 0;
4345

44-
constructor() {
46+
constructor(
47+
@ILogService private readonly _logService: ILogService
48+
) {
4549
super();
4650
this._register(toDisposable(() => this.clear()));
4751
}
@@ -101,7 +105,7 @@ abstract class TaskQueue extends Disposable implements ITaskQueue {
101105
// Warn when the time exceeding the deadline is over 20ms, if this happens in practice the
102106
// task should be split into sub-tasks to ensure the UI remains responsive.
103107
if (lastDeadlineRemaining - taskDuration < -20) {
104-
console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(lastDeadlineRemaining - taskDuration))}ms`);
108+
this._logService.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(lastDeadlineRemaining - taskDuration))}ms`);
105109
}
106110
this._start();
107111
return;
@@ -161,8 +165,10 @@ export const IdleTaskQueue = ('requestIdleCallback' in getActiveWindow()) ? Idle
161165
export class DebouncedIdleTask {
162166
private _queue: ITaskQueue;
163167

164-
constructor() {
165-
this._queue = new IdleTaskQueue();
168+
constructor(
169+
@IInstantiationService instantiationService: IInstantiationService
170+
) {
171+
this._queue = instantiationService.createInstance(IdleTaskQueue);
166172
}
167173

168174
public set(task: () => boolean | void): void {

0 commit comments

Comments
 (0)