@lynx-js/web-worker-runtime 0.14.1 → 0.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/backgroundThread/background-apis/createTimingSystem.d.ts +1 -1
- package/dist/backgroundThread/background-apis/createTimingSystem.js +17 -15
- package/dist/mainThread/crossThreadHandlers/createMainthreadMarkTimingInternal.d.ts +4 -1
- package/dist/mainThread/crossThreadHandlers/createMainthreadMarkTimingInternal.js +18 -8
- package/dist/mainThread/startMainThread.js +2 -2
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @lynx-js/web-worker-runtime
|
|
2
2
|
|
|
3
|
+
## 0.14.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- feat: merge multiple markTiming RPC communication events together and send them together, which can effectively reduce the number of RPC communications. ([#1178](https://github.com/lynx-family/lynx-stack/pull/1178))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`e44b146`](https://github.com/lynx-family/lynx-stack/commit/e44b146b1bc2b58c0347af7fb4e4157688e07e36), [`5a9b38b`](https://github.com/lynx-family/lynx-stack/commit/5a9b38b783e611aa9761c4cd52191172270c09c7), [`6ca5b91`](https://github.com/lynx-family/lynx-stack/commit/6ca5b9106aade393dfac88914b160960a61a82f2)]:
|
|
10
|
+
- @lynx-js/web-mainthread-apis@0.14.2
|
|
11
|
+
- @lynx-js/web-constants@0.14.2
|
|
12
|
+
- @lynx-js/web-worker-rpc@0.14.2
|
|
13
|
+
|
|
3
14
|
## 0.14.1
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -5,4 +5,4 @@ export type TimingSystem = {
|
|
|
5
5
|
markTimingInternal: (timingKey: string, pipelineId?: string) => void;
|
|
6
6
|
pipelineIdToTimingFlags: Map<string, string[]>;
|
|
7
7
|
};
|
|
8
|
-
export declare function createTimingSystem(mainThreadRpc: Rpc,
|
|
8
|
+
export declare function createTimingSystem(mainThreadRpc: Rpc, uiThreadRpc: Rpc): TimingSystem;
|
|
@@ -6,25 +6,27 @@ const ListenerKeys = {
|
|
|
6
6
|
onSetup: 'lynx.performance.timing.onSetup',
|
|
7
7
|
onUpdate: 'lynx.performance.timing.onUpdate',
|
|
8
8
|
};
|
|
9
|
-
export function createTimingSystem(mainThreadRpc,
|
|
9
|
+
export function createTimingSystem(mainThreadRpc, uiThreadRpc) {
|
|
10
10
|
let isFp = true;
|
|
11
11
|
const setupTiming = {};
|
|
12
12
|
const pipelineIdToTiming = new Map();
|
|
13
13
|
const pipelineIdToTimingFlags = new Map();
|
|
14
|
-
const dispatchLynxViewEvent =
|
|
14
|
+
const dispatchLynxViewEvent = uiThreadRpc.createCall(dispatchLynxViewEventEndpoint);
|
|
15
15
|
let commonTimingFlags = [];
|
|
16
|
-
function markTimingInternal(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
pipelineIdToTiming.
|
|
16
|
+
function markTimingInternal(markTimingRecords) {
|
|
17
|
+
for (let { timingKey, pipelineId, timeStamp } of markTimingRecords) {
|
|
18
|
+
if (!timeStamp)
|
|
19
|
+
timeStamp = performance.now() + performance.timeOrigin;
|
|
20
|
+
if (!pipelineId) {
|
|
21
|
+
setupTiming[timingKey] = timeStamp;
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (!pipelineIdToTiming.has(pipelineId)) {
|
|
25
|
+
pipelineIdToTiming.set(pipelineId, {});
|
|
26
|
+
}
|
|
27
|
+
const timingInfo = pipelineIdToTiming.get(pipelineId);
|
|
28
|
+
timingInfo[timingKey] = timeStamp;
|
|
25
29
|
}
|
|
26
|
-
const timingInfo = pipelineIdToTiming.get(pipelineId);
|
|
27
|
-
timingInfo[timingKey] = timeStamp;
|
|
28
30
|
}
|
|
29
31
|
const registerGlobalEmitter = (globalEventEmitter) => {
|
|
30
32
|
mainThreadRpc.registerHandler(postTimingFlagsEndpoint, (timingFlags, pipelineId) => {
|
|
@@ -74,9 +76,9 @@ export function createTimingSystem(mainThreadRpc, backgroundThreadRpc) {
|
|
|
74
76
|
});
|
|
75
77
|
};
|
|
76
78
|
mainThreadRpc.registerHandler(markTimingEndpoint, markTimingInternal);
|
|
77
|
-
|
|
79
|
+
uiThreadRpc.registerHandler(markTimingEndpoint, markTimingInternal);
|
|
78
80
|
return {
|
|
79
|
-
markTimingInternal,
|
|
81
|
+
markTimingInternal: (timingKey, pipelineId, timeStamp) => markTimingInternal([{ timingKey, pipelineId, timeStamp }]),
|
|
80
82
|
registerGlobalEmitter,
|
|
81
83
|
pipelineIdToTimingFlags,
|
|
82
84
|
};
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import type { Rpc } from '@lynx-js/web-worker-rpc';
|
|
2
|
-
export declare function createMarkTimingInternal(
|
|
2
|
+
export declare function createMarkTimingInternal(backgroundThreadRpc: Rpc): {
|
|
3
|
+
markTimingInternal: (timingKey: string, pipelineId?: string, timeStamp?: number) => void;
|
|
4
|
+
flushMarkTimingInternal: () => void;
|
|
5
|
+
};
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
// Copyright 2023 The Lynx Authors. All rights reserved.
|
|
2
2
|
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
|
-
import { markTimingEndpoint } from '@lynx-js/web-constants';
|
|
5
|
-
export function createMarkTimingInternal(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
import { dispatchMarkTiming, flushMarkTiming, markTimingEndpoint, } from '@lynx-js/web-constants';
|
|
5
|
+
export function createMarkTimingInternal(backgroundThreadRpc) {
|
|
6
|
+
const markTiming = backgroundThreadRpc.createCall(markTimingEndpoint);
|
|
7
|
+
const cacheMarkTimings = {
|
|
8
|
+
records: [],
|
|
9
|
+
timeout: null,
|
|
10
|
+
};
|
|
11
|
+
return {
|
|
12
|
+
markTimingInternal: (timingKey, pipelineId, timeStamp) => {
|
|
13
|
+
dispatchMarkTiming({
|
|
14
|
+
timingKey,
|
|
15
|
+
pipelineId,
|
|
16
|
+
timeStamp,
|
|
17
|
+
markTiming,
|
|
18
|
+
cacheMarkTimings,
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
flushMarkTimingInternal: () => flushMarkTiming(markTiming, cacheMarkTimings),
|
|
12
22
|
};
|
|
13
23
|
}
|
|
14
24
|
//# sourceMappingURL=createMainthreadMarkTimingInternal.js.map
|
|
@@ -11,7 +11,7 @@ const { prepareMainThreadAPIs } = await import('@lynx-js/web-mainthread-apis');
|
|
|
11
11
|
export function startMainThreadWorker(uiThreadPort, backgroundThreadPort) {
|
|
12
12
|
const uiThreadRpc = new Rpc(uiThreadPort, 'main-to-ui');
|
|
13
13
|
const backgroundThreadRpc = new Rpc(backgroundThreadPort, 'main-to-bg');
|
|
14
|
-
const markTimingInternal = createMarkTimingInternal(backgroundThreadRpc);
|
|
14
|
+
const { markTimingInternal, flushMarkTimingInternal } = createMarkTimingInternal(backgroundThreadRpc);
|
|
15
15
|
const uiFlush = uiThreadRpc.createCall(flushElementTreeEndpoint);
|
|
16
16
|
const reportError = uiThreadRpc.createCall(reportErrorEndpoint);
|
|
17
17
|
const triggerI18nResourceFallback = (options) => {
|
|
@@ -25,7 +25,7 @@ export function startMainThreadWorker(uiThreadPort, backgroundThreadPort) {
|
|
|
25
25
|
});
|
|
26
26
|
const i18nResources = new I18nResources();
|
|
27
27
|
uiThreadRpc.registerHandler(postOffscreenEventEndpoint, docu[_onEvent]);
|
|
28
|
-
const { startMainThread } = prepareMainThreadAPIs(backgroundThreadRpc, docu, docu.createElement.bind(docu), docu.commit.bind(docu), markTimingInternal, reportError, triggerI18nResourceFallback, (initI18nResources) => {
|
|
28
|
+
const { startMainThread } = prepareMainThreadAPIs(backgroundThreadRpc, docu, docu.createElement.bind(docu), docu.commit.bind(docu), markTimingInternal, flushMarkTimingInternal, reportError, triggerI18nResourceFallback, (initI18nResources) => {
|
|
29
29
|
i18nResources.setData(initI18nResources);
|
|
30
30
|
return i18nResources;
|
|
31
31
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-worker-runtime",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@lynx-js/offscreen-document": "0.1.2",
|
|
26
|
-
"@lynx-js/web-constants": "0.14.
|
|
27
|
-
"@lynx-js/web-mainthread-apis": "0.14.
|
|
28
|
-
"@lynx-js/web-worker-rpc": "0.14.
|
|
26
|
+
"@lynx-js/web-constants": "0.14.2",
|
|
27
|
+
"@lynx-js/web-mainthread-apis": "0.14.2",
|
|
28
|
+
"@lynx-js/web-worker-rpc": "0.14.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@lynx-js/lynx-core": "0.1.2"
|