Running buffer slicing when browser is idle (#3050)
* Fixed tracker uploadOfflineRecording * Make FlushBuffer perform slicing when browser is idle * Use map function to cast away proxy objects in flushBuffer
This commit is contained in:
parent
6b26f85d6e
commit
51496ae5e2
1 changed files with 14 additions and 4 deletions
|
|
@ -1635,7 +1635,7 @@ export default class App {
|
||||||
}
|
}
|
||||||
|
|
||||||
flushBuffer = async (buffer: Message[]) => {
|
flushBuffer = async (buffer: Message[]) => {
|
||||||
return new Promise((res) => {
|
return new Promise((res, reject) => {
|
||||||
if (buffer.length === 0) {
|
if (buffer.length === 0) {
|
||||||
res(null);
|
res(null);
|
||||||
return;
|
return;
|
||||||
|
|
@ -1648,9 +1648,19 @@ export default class App {
|
||||||
endIndex++;
|
endIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
const messagesBatch = buffer.splice(0, endIndex);
|
requestIdleCb(() => {
|
||||||
this.postToWorker(messagesBatch);
|
try {
|
||||||
res(null);
|
const messagesBatch = buffer.splice(0, endIndex);
|
||||||
|
|
||||||
|
// Cast out the proxy object to a regular array.
|
||||||
|
this.postToWorker(messagesBatch.map(x => [...x]));
|
||||||
|
|
||||||
|
res(null);
|
||||||
|
} catch (e) {
|
||||||
|
this._debug('flushBuffer', e);
|
||||||
|
reject(e);
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue