Skip to content

Commit 8fe5ce7

Browse files
authored
the use of worker does not depend on the map (#1814)
* the use of worker does not depend on the map * update
1 parent fc3dde1 commit 8fe5ce7

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/core/worker/WorkerPool.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { requestAnimFrame } from '../util';
12
import { getWorkerSourcePath } from './Worker';
23

34
const hardwareConcurrency = typeof window !== 'undefined' ? (window.navigator.hardwareConcurrency || 4) : 0;
@@ -98,10 +99,17 @@ export default class WorkerPool {
9899
}
99100

100101
let globalWorkerPool;
101-
102102
export function getGlobalWorkerPool() {
103103
if (!globalWorkerPool) {
104104
globalWorkerPool = new WorkerPool();
105105
}
106106
return globalWorkerPool;
107107
}
108+
109+
function frameLoop() {
110+
getGlobalWorkerPool().commit();
111+
requestAnimFrame(frameLoop);
112+
}
113+
if (requestAnimFrame) {
114+
requestAnimFrame(frameLoop);
115+
}

src/renderer/map/MapCanvasRenderer.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import Point from '../../geo/Point';
55
import Canvas2D from '../../core/Canvas';
66
import MapRenderer from './MapRenderer';
77
import Map from '../../map/Map';
8-
import { getGlobalWorkerPool } from '../../core/worker/WorkerPool';
98

109
/**
1110
* @classdesc
@@ -612,7 +611,6 @@ class MapCanvasRenderer extends MapRenderer {
612611
this._frameTimestamp = framestamp;
613612
this._resizeCount = 0;
614613
this.renderFrame(framestamp);
615-
getGlobalWorkerPool().commit();
616614
// Keep registering ourselves for the next animation frame
617615
this._animationFrame = requestAnimFrame((framestamp) => { this._frameLoop(framestamp); });
618616
}

0 commit comments

Comments
 (0)