Skip to content

Commit

Permalink
remove vis data workers
Browse files Browse the repository at this point in the history
  • Loading branch information
interim17 committed Oct 15, 2024
1 parent 346cf56 commit 1650e3d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 36 deletions.
1 change: 0 additions & 1 deletion src/controller/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ export default class SimulariumController {

this.visData.WaitForFrame(0);
this.visData.clearForNewTrajectory();
this.visData.cancelAllWorkers();

this.stop();

Expand Down
36 changes: 1 addition & 35 deletions src/simularium/VisData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { noop } from "lodash";

import { nullCachedFrame } from "../util";

import * as util from "./ThreadUtil";
import { VisDataMessage, CachedFrame } from "./types";
import { parseVisDataMessage } from "./VisDataParse";
import { VisDataCache } from "./VisDataCache";
Expand All @@ -11,7 +10,6 @@ import { BYTE_SIZE_64_BIT_NUM } from "../constants";

class VisData {
public frameCache: VisDataCache;
private webWorker: Worker | null;

private frameToWaitFor: number;
private lockedForFrame: boolean;
Expand All @@ -38,21 +36,7 @@ class VisData {
return frameData;
}

private setupWebWorker() {
this.webWorker = new Worker(
new URL("../visGeometry/workers/visDataWorker", import.meta.url),
{ type: "module" }
);
this.webWorker.onmessage = (event) => {
this.addFrameToCache(event.data);
};
}

public constructor() {
this.webWorker = null;
if (util.ThreadUtil.browserSupportsWebWorkers()) {
this.setupWebWorker();
}
this.currentFrameNumber = -1;
this.frameCache = new VisDataCache();
this.frameToWaitFor = 0;
Expand Down Expand Up @@ -127,17 +111,6 @@ class VisData {
this.clearCache();
}

public cancelAllWorkers(): void {
// we need to be able to terminate any queued work in the worker during trajectory changeovers
if (
util.ThreadUtil.browserSupportsWebWorkers() &&
this.webWorker !== null
) {
this.webWorker.terminate();
this.setupWebWorker();
}
}

private parseAgentsFromVisDataMessage(msg: VisDataMessage): void {
/**
* visDataMsg = {
Expand Down Expand Up @@ -170,14 +143,7 @@ class VisData {
this.frameExceedsCacheSizeError(parsedMsg.size);
return;
}
if (
util.ThreadUtil.browserSupportsWebWorkers() &&
this.webWorker !== null
) {
this.webWorker.postMessage(parsedMsg);
} else {
this.addFrameToCache(parsedMsg);
}
this.addFrameToCache(parsedMsg);
}

public parseAgentsFromFrameData(msg: VisDataMessage | ArrayBuffer): void {
Expand Down

0 comments on commit 1650e3d

Please sign in to comment.