@cloudcare/browser-rum 3.3.5 → 3.3.7
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/README.md +24 -3
- package/README.zh.md +19 -3
- package/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/boot/buildEnv.js.map +1 -1
- package/cjs/boot/perStartRum.js +42 -6
- package/cjs/boot/perStartRum.js.map +1 -1
- package/cjs/boot/recorderApi.js +190 -195
- package/cjs/boot/recorderApi.js.map +1 -1
- package/cjs/boot/recorderApiStub.js +3 -29
- package/cjs/boot/recorderApiStub.js.map +1 -1
- package/cjs/boot/rum.entry.js.map +1 -1
- package/cjs/boot/rum.js +8 -0
- package/cjs/boot/rum.js.map +1 -1
- package/cjs/boot/rum.slim.entry.js.map +1 -1
- package/cjs/boot/rumEntryFactory.js.map +1 -1
- package/cjs/boot/rumPublicApi.js +36 -3
- package/cjs/boot/rumPublicApi.js.map +1 -1
- package/cjs/boot/rumRecorderApiStub.js.map +1 -1
- package/cjs/boot/rumSlimConfiguration.js.map +1 -1
- package/cjs/boot/sessionReplayPublicApi.js +14 -27
- package/cjs/boot/sessionReplayPublicApi.js.map +1 -1
- package/cjs/boot/startRecording.js +333 -108
- package/cjs/boot/startRecording.js.map +1 -1
- package/cjs/constants.js.map +1 -1
- package/cjs/domain/assembly.js +1 -7
- package/cjs/domain/assembly.js.map +1 -1
- package/cjs/domain/configuration.js +38 -43
- package/cjs/domain/configuration.js.map +1 -1
- package/cjs/domain/contexts/commonContext.js.map +1 -1
- package/cjs/domain/contexts/displayContext.js.map +1 -1
- package/cjs/domain/contexts/foregroundContexts.js.map +1 -1
- package/cjs/domain/contexts/internalContext.js.map +1 -1
- package/cjs/domain/contexts/pageStateHistory.js.map +1 -1
- package/cjs/domain/contexts/urlContexts.js +20 -2
- package/cjs/domain/contexts/urlContexts.js.map +1 -1
- package/cjs/domain/contexts/viewContexts.js +2 -2
- package/cjs/domain/contexts/viewContexts.js.map +1 -1
- package/cjs/domain/deflate/deflateEncoder.js +517 -39
- package/cjs/domain/deflate/deflateEncoder.js.map +1 -1
- package/cjs/domain/deflate/deflateWorker.js +194 -115
- package/cjs/domain/deflate/deflateWorker.js.map +1 -1
- package/cjs/domain/deflate/index.js.map +1 -1
- package/cjs/domain/domMutationObservable.js.map +1 -1
- package/cjs/domain/encoderStreamId.js.map +1 -1
- package/cjs/domain/firstInputPolyfill.js.map +1 -1
- package/cjs/domain/initViewportObservable.js.map +1 -1
- package/cjs/domain/locationChangeObservable.js.map +1 -1
- package/cjs/domain/performanceObservable.js.map +1 -1
- package/cjs/domain/performanceUtils.js.map +1 -1
- package/cjs/domain/plugins.js +67 -0
- package/cjs/domain/plugins.js.map +1 -0
- package/cjs/domain/replay/record/canvasAutoSnapshot.js.map +1 -1
- package/cjs/domain/replay/record/canvasCommandCapture.js +968 -167
- package/cjs/domain/replay/record/canvasCommandCapture.js.map +1 -1
- package/cjs/domain/replay/record/canvasCommandObserver.js +1058 -119
- package/cjs/domain/replay/record/canvasCommandObserver.js.map +1 -1
- package/cjs/domain/replay/record/canvasCommandSerializeArgs.js +61 -37
- package/cjs/domain/replay/record/canvasCommandSerializeArgs.js.map +1 -1
- package/cjs/domain/replay/record/canvasContext.js +63 -0
- package/cjs/domain/replay/record/canvasContext.js.map +1 -0
- package/cjs/domain/replay/record/canvasContinuousScheduler.js +246 -118
- package/cjs/domain/replay/record/canvasContinuousScheduler.js.map +1 -1
- package/cjs/domain/replay/record/canvasEncodeBridge.js +539 -87
- package/cjs/domain/replay/record/canvasEncodeBridge.js.map +1 -1
- package/cjs/domain/replay/record/canvasEncodeWorker.js +50 -32
- package/cjs/domain/replay/record/canvasEncodeWorker.js.map +1 -1
- package/cjs/domain/replay/record/canvasFrameSignature.js +49 -17
- package/cjs/domain/replay/record/canvasFrameSignature.js.map +1 -1
- package/cjs/domain/replay/record/canvasMutationRecord.js.map +1 -1
- package/cjs/domain/replay/record/canvasObserver.js +295 -59
- package/cjs/domain/replay/record/canvasObserver.js.map +1 -1
- package/cjs/domain/replay/record/canvasSerializeArgs.js.map +1 -1
- package/cjs/domain/replay/record/canvasWebGLPluginHost.js +33 -0
- package/cjs/domain/replay/record/canvasWebGLPluginHost.js.map +1 -0
- package/cjs/domain/replay/record/elementsScrollPositions.js +3 -0
- package/cjs/domain/replay/record/elementsScrollPositions.js.map +1 -1
- package/cjs/domain/replay/record/index.js.map +1 -1
- package/cjs/domain/replay/record/mutationBatch.js +542 -25
- package/cjs/domain/replay/record/mutationBatch.js.map +1 -1
- package/cjs/domain/replay/record/mutationObserver.js +1900 -191
- package/cjs/domain/replay/record/mutationObserver.js.map +1 -1
- package/cjs/domain/replay/record/mutationResourceBudget.js +144 -0
- package/cjs/domain/replay/record/mutationResourceBudget.js.map +1 -0
- package/cjs/domain/replay/record/observers.js +222 -53
- package/cjs/domain/replay/record/observers.js.map +1 -1
- package/cjs/domain/replay/record/privacy.js +31 -8
- package/cjs/domain/replay/record/privacy.js.map +1 -1
- package/cjs/domain/replay/record/record.js +3083 -321
- package/cjs/domain/replay/record/record.js.map +1 -1
- package/cjs/domain/replay/record/serializationUtils.js +426 -26
- package/cjs/domain/replay/record/serializationUtils.js.map +1 -1
- package/cjs/domain/replay/record/serialize.js +259 -49
- package/cjs/domain/replay/record/serialize.js.map +1 -1
- package/cjs/domain/replay/record/shadowRootsController.js +875 -21
- package/cjs/domain/replay/record/shadowRootsController.js.map +1 -1
- package/cjs/domain/replay/record/utils.js.map +1 -1
- package/cjs/domain/replay/record/viewports.js.map +1 -1
- package/cjs/domain/replay/replayStats.js.map +1 -1
- package/cjs/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -1
- package/cjs/domain/replay/segmentCollection/index.js.map +1 -1
- package/cjs/domain/replay/segmentCollection/segment.js +315 -11
- package/cjs/domain/replay/segmentCollection/segment.js.map +1 -1
- package/cjs/domain/replay/segmentCollection/segmentCollection.js +956 -71
- package/cjs/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/cjs/domain/replay/startRecordBridge.js.map +1 -1
- package/cjs/domain/requestCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/actionCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/clickChain.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/computeFrustration.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/getActionNameFromElement.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/getSelectorsFromElement.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/interactionSelectorCache.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
- package/cjs/domain/rumEventsCollection/error/errorCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/error/trackConsoleError.js.map +1 -1
- package/cjs/domain/rumEventsCollection/error/trackReportError.js.map +1 -1
- package/cjs/domain/rumEventsCollection/longTask/longAnimationFrameCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/longTask/longTaskCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +56 -0
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceTrackerManager.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/webSocketCollection.js +196 -0
- package/cjs/domain/rumEventsCollection/resource/webSocketCollection.js.map +1 -0
- package/cjs/domain/rumEventsCollection/view/interactionCountPolyfill.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstContentfulPaint.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstHidden.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstInput.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackInitialViewTimings.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackLoadingTime.js +8 -3
- package/cjs/domain/rumEventsCollection/view/trackLoadingTime.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackScrollMetrics.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackViewEventCounts.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackViews.js +31 -12
- package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
- package/cjs/domain/rumSessionManager.js +23 -3
- package/cjs/domain/rumSessionManager.js.map +1 -1
- package/cjs/domain/tracing/ddtraceTracer.js.map +1 -1
- package/cjs/domain/tracing/getDocumentTraceId.js.map +1 -1
- package/cjs/domain/tracing/jaegerTracer.js.map +1 -1
- package/cjs/domain/tracing/sampler.js.map +1 -1
- package/cjs/domain/tracing/skywalkingTracer.js.map +1 -1
- package/cjs/domain/tracing/traceIdentifier.js.map +1 -1
- package/cjs/domain/tracing/tracer.js +2 -2
- package/cjs/domain/tracing/tracer.js.map +1 -1
- package/cjs/domain/tracing/w3cTraceParentTracer.js.map +1 -1
- package/cjs/domain/tracing/zipkinMultiTracer.js.map +1 -1
- package/cjs/domain/tracing/zipkinSingleTracer.js.map +1 -1
- package/cjs/domain/trackEventCounts.js.map +1 -1
- package/cjs/domain/usr/index.js.map +1 -1
- package/cjs/domain/waitPageActivityEnd.js.map +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/transport/startRumBatch.js +3 -1
- package/cjs/transport/startRumBatch.js.map +1 -1
- package/cjs/transport/startRumEventBridge.js.map +1 -1
- package/cjs/types/index.js.map +1 -1
- package/cjs/types/sessionReplayConstants.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/buildEnv.js.map +1 -1
- package/esm/boot/perStartRum.js +42 -6
- package/esm/boot/perStartRum.js.map +1 -1
- package/esm/boot/recorderApi.js +192 -197
- package/esm/boot/recorderApi.js.map +1 -1
- package/esm/boot/recorderApiStub.js +3 -29
- package/esm/boot/recorderApiStub.js.map +1 -1
- package/esm/boot/rum.entry.js.map +1 -1
- package/esm/boot/rum.js +8 -0
- package/esm/boot/rum.js.map +1 -1
- package/esm/boot/rum.slim.entry.js.map +1 -1
- package/esm/boot/rumEntryFactory.js.map +1 -1
- package/esm/boot/rumPublicApi.js +36 -3
- package/esm/boot/rumPublicApi.js.map +1 -1
- package/esm/boot/rumRecorderApiStub.js.map +1 -1
- package/esm/boot/rumSlimConfiguration.js.map +1 -1
- package/esm/boot/sessionReplayPublicApi.js +14 -27
- package/esm/boot/sessionReplayPublicApi.js.map +1 -1
- package/esm/boot/startRecording.js +334 -109
- package/esm/boot/startRecording.js.map +1 -1
- package/esm/constants.js.map +1 -1
- package/esm/domain/assembly.js +1 -7
- package/esm/domain/assembly.js.map +1 -1
- package/esm/domain/configuration.js +39 -44
- package/esm/domain/configuration.js.map +1 -1
- package/esm/domain/contexts/commonContext.js.map +1 -1
- package/esm/domain/contexts/displayContext.js.map +1 -1
- package/esm/domain/contexts/foregroundContexts.js.map +1 -1
- package/esm/domain/contexts/internalContext.js.map +1 -1
- package/esm/domain/contexts/pageStateHistory.js.map +1 -1
- package/esm/domain/contexts/urlContexts.js +21 -3
- package/esm/domain/contexts/urlContexts.js.map +1 -1
- package/esm/domain/contexts/viewContexts.js +2 -2
- package/esm/domain/contexts/viewContexts.js.map +1 -1
- package/esm/domain/deflate/deflateEncoder.js +517 -39
- package/esm/domain/deflate/deflateEncoder.js.map +1 -1
- package/esm/domain/deflate/deflateWorker.js +193 -116
- package/esm/domain/deflate/deflateWorker.js.map +1 -1
- package/esm/domain/deflate/index.js.map +1 -1
- package/esm/domain/domMutationObservable.js.map +1 -1
- package/esm/domain/encoderStreamId.js.map +1 -1
- package/esm/domain/firstInputPolyfill.js.map +1 -1
- package/esm/domain/initViewportObservable.js.map +1 -1
- package/esm/domain/locationChangeObservable.js.map +1 -1
- package/esm/domain/performanceObservable.js.map +1 -1
- package/esm/domain/performanceUtils.js.map +1 -1
- package/esm/domain/plugins.js +59 -0
- package/esm/domain/plugins.js.map +1 -0
- package/esm/domain/replay/record/canvasAutoSnapshot.js.map +1 -1
- package/esm/domain/replay/record/canvasCommandCapture.js +968 -168
- package/esm/domain/replay/record/canvasCommandCapture.js.map +1 -1
- package/esm/domain/replay/record/canvasCommandObserver.js +1058 -119
- package/esm/domain/replay/record/canvasCommandObserver.js.map +1 -1
- package/esm/domain/replay/record/canvasCommandSerializeArgs.js +60 -37
- package/esm/domain/replay/record/canvasCommandSerializeArgs.js.map +1 -1
- package/esm/domain/replay/record/canvasContext.js +50 -0
- package/esm/domain/replay/record/canvasContext.js.map +1 -0
- package/esm/domain/replay/record/canvasContinuousScheduler.js +246 -118
- package/esm/domain/replay/record/canvasContinuousScheduler.js.map +1 -1
- package/esm/domain/replay/record/canvasEncodeBridge.js +539 -87
- package/esm/domain/replay/record/canvasEncodeBridge.js.map +1 -1
- package/esm/domain/replay/record/canvasEncodeWorker.js +51 -33
- package/esm/domain/replay/record/canvasEncodeWorker.js.map +1 -1
- package/esm/domain/replay/record/canvasFrameSignature.js +50 -17
- package/esm/domain/replay/record/canvasFrameSignature.js.map +1 -1
- package/esm/domain/replay/record/canvasMutationRecord.js.map +1 -1
- package/esm/domain/replay/record/canvasObserver.js +295 -59
- package/esm/domain/replay/record/canvasObserver.js.map +1 -1
- package/esm/domain/replay/record/canvasSerializeArgs.js.map +1 -1
- package/esm/domain/replay/record/canvasWebGLPluginHost.js +26 -0
- package/esm/domain/replay/record/canvasWebGLPluginHost.js.map +1 -0
- package/esm/domain/replay/record/elementsScrollPositions.js +3 -0
- package/esm/domain/replay/record/elementsScrollPositions.js.map +1 -1
- package/esm/domain/replay/record/index.js.map +1 -1
- package/esm/domain/replay/record/mutationBatch.js +541 -25
- package/esm/domain/replay/record/mutationBatch.js.map +1 -1
- package/esm/domain/replay/record/mutationObserver.js +1892 -195
- package/esm/domain/replay/record/mutationObserver.js.map +1 -1
- package/esm/domain/replay/record/mutationResourceBudget.js +137 -0
- package/esm/domain/replay/record/mutationResourceBudget.js.map +1 -0
- package/esm/domain/replay/record/observers.js +224 -55
- package/esm/domain/replay/record/observers.js.map +1 -1
- package/esm/domain/replay/record/privacy.js +30 -7
- package/esm/domain/replay/record/privacy.js.map +1 -1
- package/esm/domain/replay/record/record.js +3086 -325
- package/esm/domain/replay/record/record.js.map +1 -1
- package/esm/domain/replay/record/serializationUtils.js +422 -25
- package/esm/domain/replay/record/serializationUtils.js.map +1 -1
- package/esm/domain/replay/record/serialize.js +258 -50
- package/esm/domain/replay/record/serialize.js.map +1 -1
- package/esm/domain/replay/record/shadowRootsController.js +875 -21
- package/esm/domain/replay/record/shadowRootsController.js.map +1 -1
- package/esm/domain/replay/record/utils.js.map +1 -1
- package/esm/domain/replay/record/viewports.js.map +1 -1
- package/esm/domain/replay/replayStats.js.map +1 -1
- package/esm/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -1
- package/esm/domain/replay/segmentCollection/index.js.map +1 -1
- package/esm/domain/replay/segmentCollection/segment.js +315 -10
- package/esm/domain/replay/segmentCollection/segment.js.map +1 -1
- package/esm/domain/replay/segmentCollection/segmentCollection.js +957 -72
- package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/esm/domain/replay/startRecordBridge.js.map +1 -1
- package/esm/domain/requestCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/actionCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/clickChain.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/computeFrustration.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/getActionNameFromElement.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/interactionSelectorCache.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
- package/esm/domain/rumEventsCollection/error/errorCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/error/trackConsoleError.js.map +1 -1
- package/esm/domain/rumEventsCollection/error/trackReportError.js.map +1 -1
- package/esm/domain/rumEventsCollection/longTask/longAnimationFrameCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/longTask/longTaskCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js +55 -0
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceTrackerManager.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/webSocketCollection.js +189 -0
- package/esm/domain/rumEventsCollection/resource/webSocketCollection.js.map +1 -0
- package/esm/domain/rumEventsCollection/view/interactionCountPolyfill.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackFirstContentfulPaint.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackFirstHidden.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackFirstInput.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackInitialViewTimings.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackLoadingTime.js +8 -3
- package/esm/domain/rumEventsCollection/view/trackLoadingTime.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackScrollMetrics.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackViewEventCounts.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackViews.js +32 -13
- package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
- package/esm/domain/rumSessionManager.js +24 -4
- package/esm/domain/rumSessionManager.js.map +1 -1
- package/esm/domain/tracing/ddtraceTracer.js.map +1 -1
- package/esm/domain/tracing/getDocumentTraceId.js.map +1 -1
- package/esm/domain/tracing/jaegerTracer.js.map +1 -1
- package/esm/domain/tracing/sampler.js.map +1 -1
- package/esm/domain/tracing/skywalkingTracer.js.map +1 -1
- package/esm/domain/tracing/traceIdentifier.js.map +1 -1
- package/esm/domain/tracing/tracer.js +2 -2
- package/esm/domain/tracing/tracer.js.map +1 -1
- package/esm/domain/tracing/w3cTraceParentTracer.js.map +1 -1
- package/esm/domain/tracing/zipkinMultiTracer.js.map +1 -1
- package/esm/domain/tracing/zipkinSingleTracer.js.map +1 -1
- package/esm/domain/trackEventCounts.js.map +1 -1
- package/esm/domain/usr/index.js.map +1 -1
- package/esm/domain/waitPageActivityEnd.js.map +1 -1
- package/esm/index.js.map +1 -1
- package/esm/transport/startRumBatch.js +4 -2
- package/esm/transport/startRumBatch.js.map +1 -1
- package/esm/transport/startRumEventBridge.js.map +1 -1
- package/esm/types/index.js.map +1 -1
- package/esm/types/sessionReplayConstants.js.map +1 -1
- package/package.json +12 -7
- package/src/boot/perStartRum.js +47 -7
- package/src/boot/recorderApi.js +271 -220
- package/src/boot/recorderApiStub.js +3 -29
- package/src/boot/rum.js +11 -0
- package/src/boot/rumPublicApi.js +38 -3
- package/src/boot/sessionReplayPublicApi.js +15 -28
- package/src/boot/startRecording.js +429 -146
- package/src/domain/assembly.js +5 -4
- package/src/domain/configuration.js +76 -101
- package/src/domain/contexts/urlContexts.js +29 -3
- package/src/domain/contexts/viewContexts.js +2 -2
- package/src/domain/deflate/deflateEncoder.js +699 -43
- package/src/domain/deflate/deflateWorker.js +237 -136
- package/src/domain/plugins.js +94 -0
- package/src/domain/replay/record/canvasCommandCapture.js +1374 -180
- package/src/domain/replay/record/canvasCommandObserver.js +1585 -150
- package/src/domain/replay/record/canvasCommandSerializeArgs.js +79 -42
- package/src/domain/replay/record/canvasContext.js +67 -0
- package/src/domain/replay/record/canvasContinuousScheduler.js +379 -143
- package/src/domain/replay/record/canvasEncodeBridge.js +691 -106
- package/src/domain/replay/record/canvasEncodeWorker.js +67 -43
- package/src/domain/replay/record/canvasFrameSignature.js +58 -24
- package/src/domain/replay/record/canvasObserver.js +461 -89
- package/src/domain/replay/record/canvasWebGLPluginHost.js +43 -0
- package/src/domain/replay/record/elementsScrollPositions.js +3 -0
- package/src/domain/replay/record/mutationBatch.js +761 -27
- package/src/domain/replay/record/mutationObserver.js +2992 -261
- package/src/domain/replay/record/mutationResourceBudget.js +191 -0
- package/src/domain/replay/record/observers.js +367 -97
- package/src/domain/replay/record/privacy.js +34 -12
- package/src/domain/replay/record/record.js +4284 -413
- package/src/domain/replay/record/serializationUtils.js +587 -28
- package/src/domain/replay/record/serialize.js +432 -66
- package/src/domain/replay/record/shadowRootsController.js +1108 -30
- package/src/domain/replay/segmentCollection/segment.js +441 -11
- package/src/domain/replay/segmentCollection/segmentCollection.js +1300 -77
- package/src/domain/rumEventsCollection/resource/resourceCollection.js +70 -0
- package/src/domain/rumEventsCollection/resource/webSocketCollection.js +271 -0
- package/src/domain/rumEventsCollection/view/trackLoadingTime.js +12 -3
- package/src/domain/rumEventsCollection/view/trackViews.js +38 -13
- package/src/domain/rumSessionManager.js +33 -2
- package/src/domain/tracing/tracer.js +4 -5
- package/src/transport/startRumBatch.js +6 -1
- package/types/index.d.ts +100 -8
- package/cjs/domain/replay/record/canvasReplayFixtures.js +0 -105
- package/cjs/domain/replay/record/canvasReplayFixtures.js.map +0 -1
- package/esm/domain/replay/record/canvasReplayFixtures.js +0 -96
- package/esm/domain/replay/record/canvasReplayFixtures.js.map +0 -1
- package/src/domain/replay/record/canvasReplayFixtures.js +0 -113
|
@@ -18,6 +18,15 @@ var SEGMENT_DURATION_LIMIT = exports.SEGMENT_DURATION_LIMIT = 5 * _browserCore.O
|
|
|
18
18
|
* ensure that we leave room for logs, rum and potential other users
|
|
19
19
|
*/
|
|
20
20
|
var SEGMENT_BYTES_LIMIT = exports.SEGMENT_BYTES_LIMIT = 60000;
|
|
21
|
+
// buildReplayPayload() exposes the compressed segment size, but sendBeacon
|
|
22
|
+
// accounts for the multipart boundaries, headers, and metadata fields too.
|
|
23
|
+
// Reserve a conservative envelope per segment so several small unload
|
|
24
|
+
// segments cannot collectively overrun the browser's exit delivery queue.
|
|
25
|
+
var SEGMENT_FORM_DATA_ESTIMATED_OVERHEAD = 2 * 1024;
|
|
26
|
+
var SEGMENT_PENDING_RAW_BYTES_LIMIT = 4 * 1024 * 1024;
|
|
27
|
+
var LOCKED_SEGMENTS_LIMIT = 12;
|
|
28
|
+
var CANVAS_FLUSH_MIN_INTERVAL = 250;
|
|
29
|
+
var MAX_CONSECUTIVE_FULL_SNAPSHOT_FAILURES = 3;
|
|
21
30
|
|
|
22
31
|
// Segments are the main data structure for session replays. They contain context information used
|
|
23
32
|
// for indexing or UI needs, and a list of records (RRWeb 'events', renamed to avoid confusing
|
|
@@ -51,6 +60,10 @@ function startSegmentCollection(lifeCycle, configuration, sessionManager, viewCo
|
|
|
51
60
|
return computeSegmentContext(configuration, sessionManager, viewContexts);
|
|
52
61
|
}, httpRequest, encoder, isLocked, (0, _browserCore.assign)({
|
|
53
62
|
flushCanvasImmediately: configuration.replayCanvasFlushImmediately,
|
|
63
|
+
pendingRawBytesLimit: SEGMENT_PENDING_RAW_BYTES_LIMIT,
|
|
64
|
+
beforePageExitFlush: undefined,
|
|
65
|
+
onReplayResetNeeded: undefined,
|
|
66
|
+
onReplayResetExhausted: undefined,
|
|
54
67
|
onSegmentFlushed: undefined
|
|
55
68
|
}, additionalOptions));
|
|
56
69
|
}
|
|
@@ -63,115 +76,987 @@ function doStartSegmentCollection(lifeCycle, getSegmentContext, httpRequest, enc
|
|
|
63
76
|
if (options === undefined) {
|
|
64
77
|
options = {};
|
|
65
78
|
}
|
|
79
|
+
var pendingRawBytesLimit = typeof options.pendingRawBytesLimit === 'number' ? options.pendingRawBytesLimit : SEGMENT_PENDING_RAW_BYTES_LIMIT;
|
|
80
|
+
var lockedSegments = [];
|
|
81
|
+
var lockedBufferGeneration = 0;
|
|
82
|
+
var reportedDropReasons = {};
|
|
83
|
+
var lastCanvasFlushAt = -Infinity;
|
|
84
|
+
var canvasFlushTimeoutId;
|
|
85
|
+
var replayResetNeeded = false;
|
|
86
|
+
var replayResetReason;
|
|
87
|
+
var replayResetNotificationSent = false;
|
|
88
|
+
var replayResetNotificationTimeoutId;
|
|
89
|
+
var activeBaselineGeneration = 0;
|
|
90
|
+
var nextBaselineGeneration = 0;
|
|
91
|
+
var baselineGenerationStates = {};
|
|
92
|
+
var transportGenerationStates = {};
|
|
93
|
+
var baselineGenerationInFlightCounts = {};
|
|
94
|
+
var pendingSegmentResultsByGeneration = {};
|
|
95
|
+
var consecutiveFullSnapshotFailures = 0;
|
|
96
|
+
var replayRecoveryExhausted = false;
|
|
97
|
+
var lifecycleSubscriptionsStopped = false;
|
|
98
|
+
var nextSegmentFlushSequence = 0;
|
|
99
|
+
var inFlightSegmentFlushes = new Set();
|
|
100
|
+
var lastAddRecordWasBackpressured = false;
|
|
101
|
+
var backpressuredSerializedRecordData = new WeakMap();
|
|
102
|
+
var unloadingTransportLatched = false;
|
|
103
|
+
var unloadingDeliveryBytesRemaining;
|
|
104
|
+
var unloadingDeliveryBudgetExhausted = false;
|
|
105
|
+
var unloadingRetryPayloadsDrained = false;
|
|
106
|
+
var mandatoryRecoveryPending = false;
|
|
107
|
+
var bufferCheckoutPending = false;
|
|
108
|
+
var activeBaselineTransaction;
|
|
66
109
|
var state = {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
110
|
+
$rStatus: SegmentCollectionStatus.WaitingForInitialRecord,
|
|
111
|
+
$rNextReason: 'init',
|
|
112
|
+
$rLocked: isLocked,
|
|
113
|
+
$rGeneration: activeBaselineGeneration
|
|
70
114
|
};
|
|
115
|
+
function prepareRecordsBeforePageExit(pageExitEvent) {
|
|
116
|
+
if (!options.beforePageExitFlush) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
options.beforePageExitFlush(pageExitEvent);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
(0, _browserCore.addTelemetryDebug)('Session Replay failed to prepare records before page exit.', {
|
|
123
|
+
reason: pageExitEvent && pageExitEvent.reason,
|
|
124
|
+
error: String(error)
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
71
128
|
var subscribeViewCreated = lifeCycle.subscribe(_browserCore.LifeCycleEventType.VIEW_CREATED, function () {
|
|
72
129
|
flushSegment('view_change');
|
|
73
130
|
});
|
|
74
131
|
var unsubscribeViewCreated = subscribeViewCreated.unsubscribe;
|
|
75
132
|
var subscribePageExited = lifeCycle.subscribe(_browserCore.LifeCycleEventType.PAGE_EXITED, function (pageExitEvent) {
|
|
133
|
+
if (state.$rStatus === SegmentCollectionStatus.Stopped) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
prepareRecordsBeforePageExit(pageExitEvent);
|
|
137
|
+
upgradeSegmentTransportsForPageExit(pageExitEvent.reason);
|
|
138
|
+
if (state.$rLocked && pageExitEvent.reason === _browserCore.PageExitReason.UNLOADING) {
|
|
139
|
+
lockedBufferGeneration += 1;
|
|
140
|
+
lockedSegments = [];
|
|
141
|
+
}
|
|
76
142
|
flushSegment(pageExitEvent.reason);
|
|
143
|
+
if (flushPendingSegmentEncodingsForUnload(pageExitEvent.reason)) {
|
|
144
|
+
// The synchronous drain releases encoder backpressure. Give staged DOM
|
|
145
|
+
// mutations one final admission pass, then flush that second segment
|
|
146
|
+
// through the same unload-safe transport.
|
|
147
|
+
prepareRecordsBeforePageExit(pageExitEvent);
|
|
148
|
+
flushSegment(pageExitEvent.reason);
|
|
149
|
+
flushPendingSegmentEncodingsForUnload(pageExitEvent.reason);
|
|
150
|
+
}
|
|
77
151
|
});
|
|
78
152
|
var unsubscribePageExited = subscribePageExited.unsubscribe;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
153
|
+
function reportDroppedRecord(reason, estimatedBytesCount) {
|
|
154
|
+
if (reportedDropReasons[reason]) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
reportedDropReasons[reason] = true;
|
|
158
|
+
(0, _browserCore.addTelemetryDebug)('Session Replay record discarded.', {
|
|
159
|
+
reason: reason,
|
|
160
|
+
estimated_bytes_count: estimatedBytesCount
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function clearReplayResetNotificationTimeout() {
|
|
164
|
+
if (replayResetNotificationTimeoutId !== undefined) {
|
|
165
|
+
(0, _browserCore.clearTimeout)(replayResetNotificationTimeoutId);
|
|
166
|
+
replayResetNotificationTimeoutId = undefined;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function getPendingRawBytesCount() {
|
|
170
|
+
return encoder.getPendingRawBytesCount ? encoder.getPendingRawBytesCount() : 0;
|
|
171
|
+
}
|
|
172
|
+
function scheduleReplayResetNotification() {
|
|
173
|
+
if (!replayResetNeeded || replayResetNotificationSent || replayResetNotificationTimeoutId !== undefined || !options.onReplayResetNeeded || state.$rStatus === SegmentCollectionStatus.Stopped || getPendingRawBytesCount() > 0) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
replayResetNotificationTimeoutId = (0, _browserCore.setTimeout)(function () {
|
|
177
|
+
replayResetNotificationTimeoutId = undefined;
|
|
178
|
+
if (!replayResetNeeded || replayResetNotificationSent || state.$rStatus === SegmentCollectionStatus.Stopped || getPendingRawBytesCount() > 0) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
replayResetNotificationSent = true;
|
|
182
|
+
options.onReplayResetNeeded(replayResetReason);
|
|
183
|
+
}, 0);
|
|
184
|
+
}
|
|
185
|
+
function markReplayResetNeeded(reason, shouldNotifyAgain) {
|
|
186
|
+
if (!replayResetNeeded || shouldNotifyAgain) {
|
|
187
|
+
replayResetReason = reason;
|
|
188
|
+
replayResetNotificationSent = false;
|
|
189
|
+
if (shouldNotifyAgain) {
|
|
190
|
+
clearReplayResetNotificationTimeout();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
replayResetNeeded = true;
|
|
194
|
+
scheduleReplayResetNotification();
|
|
195
|
+
}
|
|
196
|
+
function clearReplayResetNeeded() {
|
|
197
|
+
replayResetNeeded = false;
|
|
198
|
+
replayResetReason = undefined;
|
|
199
|
+
replayResetNotificationSent = false;
|
|
200
|
+
clearReplayResetNotificationTimeout();
|
|
201
|
+
}
|
|
202
|
+
function unsubscribeLifecycle() {
|
|
203
|
+
if (lifecycleSubscriptionsStopped) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
lifecycleSubscriptionsStopped = true;
|
|
207
|
+
unsubscribeViewCreated();
|
|
208
|
+
unsubscribePageExited();
|
|
209
|
+
}
|
|
210
|
+
function exhaustReplayRecovery(reason) {
|
|
211
|
+
if (replayRecoveryExhausted) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
replayRecoveryExhausted = true;
|
|
215
|
+
clearReplayResetNeeded();
|
|
216
|
+
clearCanvasFlushTimeout();
|
|
217
|
+
lockedBufferGeneration += 1;
|
|
218
|
+
lockedSegments = [];
|
|
219
|
+
baselineGenerationStates = {};
|
|
220
|
+
transportGenerationStates = {};
|
|
221
|
+
baselineGenerationInFlightCounts = {};
|
|
222
|
+
pendingSegmentResultsByGeneration = {};
|
|
223
|
+
if (state.$rStatus === SegmentCollectionStatus.SegmentPending) {
|
|
224
|
+
// A dependent segment can already exist when the asynchronous failure
|
|
225
|
+
// of the third replacement baseline arrives. Finalize-discard its
|
|
226
|
+
// shared deflate stream before stopping, otherwise a later explicit
|
|
227
|
+
// recorder restart can prepend these abandoned bytes to the new
|
|
228
|
+
// baseline.
|
|
229
|
+
discardCurrentSegment('recovery_exhausted');
|
|
230
|
+
}
|
|
231
|
+
state = {
|
|
232
|
+
$rStatus: SegmentCollectionStatus.Stopped,
|
|
233
|
+
$rLocked: false
|
|
234
|
+
};
|
|
235
|
+
unsubscribeLifecycle();
|
|
236
|
+
if (options.onReplayResetExhausted) {
|
|
237
|
+
options.onReplayResetExhausted(reason);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function failBaselineGeneration(baselineGeneration, reason, isFullSnapshotFailure) {
|
|
241
|
+
if (baselineGeneration > 0) {
|
|
242
|
+
baselineGenerationStates[baselineGeneration] = 'invalid';
|
|
243
|
+
delete pendingSegmentResultsByGeneration[baselineGeneration];
|
|
244
|
+
}
|
|
245
|
+
if (baselineGeneration !== activeBaselineGeneration) {
|
|
246
|
+
tryCleanupBaselineGeneration(baselineGeneration);
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
if (isFullSnapshotFailure) {
|
|
250
|
+
consecutiveFullSnapshotFailures += 1;
|
|
251
|
+
if (consecutiveFullSnapshotFailures >= MAX_CONSECUTIVE_FULL_SNAPSHOT_FAILURES) {
|
|
252
|
+
exhaustReplayRecovery(reason);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
markReplayResetNeeded(reason, true);
|
|
257
|
+
}
|
|
258
|
+
function retainBaselineGeneration(baselineGeneration) {
|
|
259
|
+
if (baselineGeneration <= 0) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
baselineGenerationInFlightCounts[baselineGeneration] = (baselineGenerationInFlightCounts[baselineGeneration] || 0) + 1;
|
|
263
|
+
}
|
|
264
|
+
function releaseBaselineGeneration(baselineGeneration) {
|
|
265
|
+
if (baselineGeneration <= 0 || !baselineGenerationInFlightCounts[baselineGeneration]) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
baselineGenerationInFlightCounts[baselineGeneration] -= 1;
|
|
269
|
+
if (!baselineGenerationInFlightCounts[baselineGeneration]) {
|
|
270
|
+
delete baselineGenerationInFlightCounts[baselineGeneration];
|
|
271
|
+
}
|
|
272
|
+
tryCleanupBaselineGeneration(baselineGeneration);
|
|
273
|
+
}
|
|
274
|
+
function tryCleanupBaselineGeneration(baselineGeneration) {
|
|
275
|
+
if (baselineGeneration <= 0 || baselineGeneration === activeBaselineGeneration || baselineGenerationInFlightCounts[baselineGeneration] || pendingSegmentResultsByGeneration[baselineGeneration]) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
delete baselineGenerationStates[baselineGeneration];
|
|
279
|
+
delete transportGenerationStates[baselineGeneration];
|
|
280
|
+
}
|
|
281
|
+
function getTransportGenerationState(baselineGeneration) {
|
|
282
|
+
if (!transportGenerationStates[baselineGeneration]) {
|
|
283
|
+
transportGenerationStates[baselineGeneration] = {
|
|
284
|
+
$rValid: true
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
return transportGenerationStates[baselineGeneration];
|
|
288
|
+
}
|
|
289
|
+
function clearCanvasFlushTimeout() {
|
|
290
|
+
if (canvasFlushTimeoutId !== undefined) {
|
|
291
|
+
(0, _browserCore.clearTimeout)(canvasFlushTimeoutId);
|
|
292
|
+
canvasFlushTimeoutId = undefined;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
function upgradeSegmentTransportsForPageExit(flushReason) {
|
|
296
|
+
if (!(0, _browserCore.isPageExitReason)(flushReason)) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
if (flushReason === _browserCore.PageExitReason.UNLOADING) {
|
|
300
|
+
unloadingTransportLatched = true;
|
|
301
|
+
if (unloadingDeliveryBytesRemaining === undefined) {
|
|
302
|
+
unloadingDeliveryBytesRemaining = SEGMENT_BYTES_LIMIT;
|
|
303
|
+
}
|
|
304
|
+
drainRetryPayloadsForUnload();
|
|
305
|
+
}
|
|
306
|
+
inFlightSegmentFlushes.forEach(function (transport) {
|
|
307
|
+
transport.$rExit = true;
|
|
308
|
+
});
|
|
309
|
+
// A dependent segment can finish encoding before its Full Snapshot and is
|
|
310
|
+
// then removed from inFlightSegmentFlushes while waiting for the baseline
|
|
311
|
+
// generation to be confirmed. Preserve the page-exit transport intent on
|
|
312
|
+
// those completed results as well. UNLOADING still uses the shared latch
|
|
313
|
+
// and aggregate delivery budget in sendSegment().
|
|
314
|
+
Object.keys(pendingSegmentResultsByGeneration).forEach(function (baselineGeneration) {
|
|
315
|
+
pendingSegmentResultsByGeneration[baselineGeneration].forEach(function (segmentResult) {
|
|
316
|
+
segmentResult.$rExit = true;
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
function flushPendingSegmentEncodingsSync() {
|
|
321
|
+
if (encoder.flushPendingActionsSync) {
|
|
322
|
+
encoder.flushPendingActionsSync(SEGMENT_BYTES_LIMIT);
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
function drainRetryPayloadsForUnload() {
|
|
328
|
+
if (unloadingRetryPayloadsDrained) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
unloadingRetryPayloadsDrained = true;
|
|
332
|
+
if (typeof httpRequest.$rDrainOnExit !== 'function') {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
var deliveryResult = httpRequest.$rDrainOnExit(unloadingDeliveryBytesRemaining);
|
|
336
|
+
if (deliveryResult && typeof deliveryResult.$rBytesCount === 'number' && isFinite(deliveryResult.$rBytesCount) && deliveryResult.$rBytesCount >= 0) {
|
|
337
|
+
unloadingDeliveryBytesRemaining = Math.max(unloadingDeliveryBytesRemaining - deliveryResult.$rBytesCount, 0);
|
|
338
|
+
if (deliveryResult.$rAllPayloadsSent === false) {
|
|
339
|
+
// Replay segments are ordered. If an older queued payload does not fit,
|
|
340
|
+
// no current tail may overtake it.
|
|
341
|
+
unloadingDeliveryBudgetExhausted = true;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
function flushPendingSegmentEncodingsForUnload(flushReason) {
|
|
346
|
+
return flushReason === _browserCore.PageExitReason.UNLOADING && flushPendingSegmentEncodingsSync();
|
|
347
|
+
}
|
|
348
|
+
function removeInFlightSegmentFlush(transport) {
|
|
349
|
+
inFlightSegmentFlushes["delete"](transport);
|
|
350
|
+
}
|
|
351
|
+
function handlePermanentTransportDrop(segmentResult, reason) {
|
|
352
|
+
// Invalidate the transport chain even after the recorder itself stopped;
|
|
353
|
+
// older queued dependents must never be promoted past the missing segment.
|
|
354
|
+
segmentResult.$rTransportGeneration.$rValid = false;
|
|
355
|
+
if (state.$rStatus === SegmentCollectionStatus.Stopped || replayRecoveryExhausted) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
var dropReason = 'transport_' + reason;
|
|
359
|
+
reportDroppedRecord(dropReason, 0);
|
|
360
|
+
// Once a segment is permanently rejected, every later incremental in its
|
|
361
|
+
// generation may depend on replay state the player will never receive.
|
|
362
|
+
// Retire the generation and gate admission until a replacement Full
|
|
363
|
+
// Snapshot establishes a new chain. A transport failure is not evidence
|
|
364
|
+
// that Full Snapshot serialization itself is permanently broken.
|
|
365
|
+
failBaselineGeneration(segmentResult.$rGeneration, dropReason, false);
|
|
366
|
+
scheduleReplayResetNotification();
|
|
367
|
+
}
|
|
368
|
+
function sendSegment(segmentResult) {
|
|
369
|
+
var metadata = segmentResult.$rMetadata;
|
|
370
|
+
var encoderResult = segmentResult.$rEncoder;
|
|
371
|
+
if (false && options.onSegmentFlushed) {
|
|
372
|
+
options.onSegmentFlushed({
|
|
373
|
+
creationReason: metadata.creation_reason,
|
|
374
|
+
flushReason: segmentResult.$rReason,
|
|
375
|
+
recordsCount: metadata.records_count,
|
|
376
|
+
recordCountsByType: segmentResult.$rCounts,
|
|
377
|
+
start: metadata.start,
|
|
378
|
+
end: metadata.end,
|
|
379
|
+
indexInView: metadata.index_in_view,
|
|
380
|
+
rawBytesCount: encoderResult.rawBytesCount
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
var shouldUseExitTransport = !segmentResult.$rRegular && (segmentResult.$rExit || (0, _browserCore.isPageExitReason)(segmentResult.$rReason) || unloadingTransportLatched);
|
|
384
|
+
var estimatedDeliveryBytesCount = encoderResult.outputBytesCount + SEGMENT_FORM_DATA_ESTIMATED_OVERHEAD;
|
|
385
|
+
if (shouldUseExitTransport && unloadingTransportLatched) {
|
|
386
|
+
if (unloadingDeliveryBudgetExhausted || estimatedDeliveryBytesCount > unloadingDeliveryBytesRemaining) {
|
|
387
|
+
unloadingDeliveryBudgetExhausted = true;
|
|
388
|
+
reportDroppedRecord('page_exit_delivery_budget', estimatedDeliveryBytesCount);
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
var payload = (0, _buildReplayPayload.buildReplayPayload)(encoderResult.output, metadata, encoderResult.rawBytesCount);
|
|
393
|
+
payload.$rExitBytesCount = estimatedDeliveryBytesCount;
|
|
394
|
+
payload.$rEnforceOrder = true;
|
|
395
|
+
payload.$rIsValid = function () {
|
|
396
|
+
return segmentResult.$rTransportGeneration.$rValid;
|
|
397
|
+
};
|
|
398
|
+
payload.$rOnPermanentDrop = function (reason) {
|
|
399
|
+
handlePermanentTransportDrop(segmentResult, reason);
|
|
400
|
+
};
|
|
401
|
+
if (shouldUseExitTransport) {
|
|
402
|
+
var exitDeliveryResult = httpRequest.sendOnExit(payload, unloadingTransportLatched ? unloadingDeliveryBytesRemaining : undefined);
|
|
403
|
+
if (unloadingTransportLatched) {
|
|
404
|
+
if (exitDeliveryResult && typeof exitDeliveryResult.$rBytesCount === 'number' && isFinite(exitDeliveryResult.$rBytesCount) && exitDeliveryResult.$rBytesCount >= 0) {
|
|
405
|
+
unloadingDeliveryBytesRemaining = Math.max(unloadingDeliveryBytesRemaining - exitDeliveryResult.$rBytesCount, 0);
|
|
406
|
+
if (!exitDeliveryResult.$rCurrentPayloadSent) {
|
|
407
|
+
unloadingDeliveryBudgetExhausted = true;
|
|
408
|
+
reportDroppedRecord('page_exit_delivery_budget', estimatedDeliveryBytesCount);
|
|
110
409
|
}
|
|
111
|
-
}
|
|
410
|
+
} else {
|
|
411
|
+
// Preserve compatibility with injected transports that predate the
|
|
412
|
+
// aggregate-budget result contract.
|
|
413
|
+
unloadingDeliveryBytesRemaining -= estimatedDeliveryBytesCount;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
} else {
|
|
417
|
+
httpRequest.send(payload);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
function retainLockedSegment(segmentResult) {
|
|
421
|
+
// A hidden-page beacon intent is only relevant while the page is hidden.
|
|
422
|
+
// If an error-session buffer is later unlocked, drain it through the
|
|
423
|
+
// regular transport instead of retaining a stale sendOnExit decision.
|
|
424
|
+
segmentResult.$rExit = false;
|
|
425
|
+
segmentResult.$rRegular = true;
|
|
426
|
+
if (replayResetNeeded) {
|
|
427
|
+
// A valid replacement snapshot clears the reset before delivery.
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
lockedSegments.push(segmentResult);
|
|
431
|
+
var latestFullSnapshotIndex = -1;
|
|
432
|
+
for (var index = lockedSegments.length - 1; index >= 0; index -= 1) {
|
|
433
|
+
if (lockedSegments[index].$rMetadata.has_full_snapshot) {
|
|
434
|
+
latestFullSnapshotIndex = index;
|
|
435
|
+
break;
|
|
112
436
|
}
|
|
113
|
-
(0, _browserCore.clearTimeout)(state.expirationTimeoutId);
|
|
114
437
|
}
|
|
438
|
+
if (latestFullSnapshotIndex > 0) {
|
|
439
|
+
lockedSegments.splice(0, latestFullSnapshotIndex);
|
|
440
|
+
}
|
|
441
|
+
if (lockedSegments.length > LOCKED_SEGMENTS_LIMIT) {
|
|
442
|
+
// Incremental segments form a dependency chain. Keeping the anchor while
|
|
443
|
+
// deleting a middle segment can leave later records referencing nodes the
|
|
444
|
+
// player never received. Retire the whole lock generation and admit no
|
|
445
|
+
// more incrementals until a replacement full snapshot starts a new chain.
|
|
446
|
+
lockedBufferGeneration += 1;
|
|
447
|
+
lockedSegments = [];
|
|
448
|
+
markReplayResetNeeded('locked_buffer_capacity');
|
|
449
|
+
// Records already admitted to the current segment still belong to the
|
|
450
|
+
// overflowing lock epoch. Finalize that segment now so its immutable
|
|
451
|
+
// epoch can reject the result, and force the replacement Full Snapshot
|
|
452
|
+
// to start a clean segment.
|
|
453
|
+
flushSegment('locked_buffer_capacity');
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
function drainLockedSegments() {
|
|
457
|
+
var segmentsToSend = lockedSegments;
|
|
458
|
+
lockedSegments = [];
|
|
459
|
+
if (segmentsToSend.length > 0 && !segmentsToSend.some(function (segmentResult) {
|
|
460
|
+
return segmentResult.$rMetadata.has_full_snapshot;
|
|
461
|
+
})) {
|
|
462
|
+
markReplayResetNeeded('locked_buffer_missing_full_snapshot');
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
segmentsToSend.forEach(function (segmentResult) {
|
|
466
|
+
segmentResult.$rExit = false;
|
|
467
|
+
segmentResult.$rRegular = true;
|
|
468
|
+
sendSegment(segmentResult);
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
function deliverSegmentResult(segmentResult) {
|
|
472
|
+
if (!segmentResult.$rLocked) {
|
|
473
|
+
sendSegment(segmentResult);
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
if (segmentResult.$rLockGeneration !== lockedBufferGeneration || segmentResult.$rReason === 'buffer_checkout' || segmentResult.$rReason === 'stop' || segmentResult.$rReason === _browserCore.PageExitReason.UNLOADING) {
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
if (state.$rLocked) {
|
|
480
|
+
retainLockedSegment(segmentResult);
|
|
481
|
+
} else {
|
|
482
|
+
segmentResult.$rExit = false;
|
|
483
|
+
segmentResult.$rRegular = true;
|
|
484
|
+
sendSegment(segmentResult);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
function retainPendingSegmentResult(baselineGeneration, segmentResult) {
|
|
488
|
+
if (!pendingSegmentResultsByGeneration[baselineGeneration]) {
|
|
489
|
+
pendingSegmentResultsByGeneration[baselineGeneration] = [];
|
|
490
|
+
}
|
|
491
|
+
pendingSegmentResultsByGeneration[baselineGeneration].push(segmentResult);
|
|
492
|
+
}
|
|
493
|
+
function confirmBaselineGeneration(baselineGeneration, segmentResult) {
|
|
494
|
+
if (replayRecoveryExhausted || baselineGenerationStates[baselineGeneration] === 'invalid') {
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
baselineGenerationStates[baselineGeneration] = 'confirmed';
|
|
498
|
+
if (baselineGeneration === activeBaselineGeneration && (!replayResetNeeded || !segmentResult.$rLocked || segmentResult.$rLockGeneration === lockedBufferGeneration)) {
|
|
499
|
+
consecutiveFullSnapshotFailures = 0;
|
|
500
|
+
clearReplayResetNeeded();
|
|
501
|
+
}
|
|
502
|
+
deliverSegmentResult(segmentResult);
|
|
503
|
+
var pendingSegmentResults = pendingSegmentResultsByGeneration[baselineGeneration] || [];
|
|
504
|
+
delete pendingSegmentResultsByGeneration[baselineGeneration];
|
|
505
|
+
pendingSegmentResults.sort(function (first, second) {
|
|
506
|
+
return first.$rSequence - second.$rSequence;
|
|
507
|
+
});
|
|
508
|
+
pendingSegmentResults.forEach(deliverSegmentResult);
|
|
509
|
+
tryCleanupBaselineGeneration(baselineGeneration);
|
|
510
|
+
}
|
|
511
|
+
function handleSuccessfulSegment(baselineGeneration, segmentResult) {
|
|
512
|
+
if (segmentResult.$rMetadata.has_full_snapshot) {
|
|
513
|
+
confirmBaselineGeneration(baselineGeneration, segmentResult);
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
if (baselineGeneration === 0) {
|
|
517
|
+
deliverSegmentResult(segmentResult);
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
var baselineState = baselineGenerationStates[baselineGeneration];
|
|
521
|
+
if (baselineState === 'confirmed') {
|
|
522
|
+
deliverSegmentResult(segmentResult);
|
|
523
|
+
} else if (baselineState === 'pending') {
|
|
524
|
+
retainPendingSegmentResult(baselineGeneration, segmentResult);
|
|
525
|
+
} else if (baselineGeneration === activeBaselineGeneration && !replayRecoveryExhausted) {
|
|
526
|
+
failBaselineGeneration(baselineGeneration, 'missing_full_snapshot', false);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
function resetState(flushReason) {
|
|
115
530
|
if (flushReason !== 'stop') {
|
|
116
531
|
state = {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
532
|
+
$rStatus: SegmentCollectionStatus.WaitingForInitialRecord,
|
|
533
|
+
$rNextReason: flushReason,
|
|
534
|
+
$rLocked: state.$rLocked,
|
|
535
|
+
$rGeneration: activeBaselineGeneration
|
|
120
536
|
};
|
|
121
537
|
} else {
|
|
122
538
|
state = {
|
|
123
|
-
|
|
124
|
-
|
|
539
|
+
$rStatus: SegmentCollectionStatus.Stopped,
|
|
540
|
+
$rLocked: false
|
|
125
541
|
};
|
|
126
542
|
}
|
|
127
543
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
544
|
+
function handleFlushedSegment(flushReason, wasLocked, lockedGeneration, baselineGeneration, metadata, encoderResult, recordCountsByType, transport) {
|
|
545
|
+
if (replayRecoveryExhausted) {
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
if (encoderResult.error) {
|
|
549
|
+
reportDroppedRecord('encoder_error', 0);
|
|
550
|
+
failBaselineGeneration(baselineGeneration, 'encoder_error', metadata.has_full_snapshot);
|
|
551
|
+
scheduleReplayResetNotification();
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
// SEGMENT_BYTES_LIMIT is a rolling target and a beacon budget, not a hard
|
|
555
|
+
// limit for regular fetch requests. The asynchronous deflate result can
|
|
556
|
+
// legitimately overshoot its estimate. Discarding that finalized segment
|
|
557
|
+
// would invalidate the replay chain and can force an impossible
|
|
558
|
+
// replacement snapshot on large pages. sendSegment() applies the bounded
|
|
559
|
+
// page-exit delivery budget separately.
|
|
560
|
+
var segmentResult = {
|
|
561
|
+
$rMetadata: metadata,
|
|
562
|
+
$rEncoder: encoderResult,
|
|
563
|
+
$rReason: flushReason,
|
|
564
|
+
$rExit: transport.$rExit,
|
|
565
|
+
$rLocked: wasLocked,
|
|
566
|
+
$rLockGeneration: lockedGeneration,
|
|
567
|
+
$rGeneration: baselineGeneration,
|
|
568
|
+
$rTransportGeneration: getTransportGenerationState(baselineGeneration),
|
|
569
|
+
$rSequence: transport.$rSequence
|
|
570
|
+
};
|
|
571
|
+
if (false) {
|
|
572
|
+
segmentResult.$rCounts = recordCountsByType;
|
|
573
|
+
}
|
|
574
|
+
handleSuccessfulSegment(baselineGeneration, segmentResult);
|
|
575
|
+
scheduleReplayResetNotification();
|
|
576
|
+
}
|
|
577
|
+
function flushSegment(flushReason, callback, isStopping) {
|
|
578
|
+
if (state.$rStatus === SegmentCollectionStatus.Stopped) {
|
|
579
|
+
if (callback) {
|
|
580
|
+
callback();
|
|
581
|
+
}
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
if (state.$rStatus === SegmentCollectionStatus.SegmentPending && state.$rMandatoryRecoveryHold) {
|
|
585
|
+
if (isStopping) {
|
|
586
|
+
mandatoryRecoveryPending = false;
|
|
587
|
+
discardCurrentSegment('mandatory_recovery_incomplete');
|
|
588
|
+
// discardCurrentSegment() normally returns to Waiting so a recovery
|
|
589
|
+
// baseline can create the next stream. A terminal stop must override
|
|
590
|
+
// that reusable state even though the discard finish is asynchronous.
|
|
591
|
+
resetState('stop');
|
|
592
|
+
}
|
|
593
|
+
if (callback) {
|
|
594
|
+
callback();
|
|
595
|
+
}
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
if (flushReason !== 'canvas_snapshot') {
|
|
599
|
+
clearCanvasFlushTimeout();
|
|
600
|
+
}
|
|
601
|
+
if (state.$rStatus === SegmentCollectionStatus.SegmentPending) {
|
|
602
|
+
var segmentState = state;
|
|
603
|
+
var wasLocked = segmentState.$rLocked;
|
|
604
|
+
var lockedGeneration = segmentState.$rLockGeneration;
|
|
605
|
+
var baselineGeneration = state.$rGeneration;
|
|
606
|
+
var transport = {
|
|
607
|
+
$rExit: (0, _browserCore.isPageExitReason)(flushReason),
|
|
608
|
+
$rSequence: ++nextSegmentFlushSequence
|
|
609
|
+
};
|
|
610
|
+
(0, _browserCore.clearTimeout)(state.$rExpiration);
|
|
611
|
+
resetState(isStopping ? 'stop' : flushReason);
|
|
612
|
+
if (!segmentState.$rSegment.isEmpty()) {
|
|
613
|
+
inFlightSegmentFlushes.add(transport);
|
|
614
|
+
retainBaselineGeneration(baselineGeneration);
|
|
615
|
+
segmentState.$rSegment.flush(function (metadata, encoderResult, recordCountsByType) {
|
|
616
|
+
removeInFlightSegmentFlush(transport);
|
|
617
|
+
try {
|
|
618
|
+
handleFlushedSegment(flushReason, wasLocked, lockedGeneration, baselineGeneration, metadata, encoderResult, recordCountsByType, transport);
|
|
619
|
+
} finally {
|
|
620
|
+
releaseBaselineGeneration(baselineGeneration);
|
|
621
|
+
}
|
|
622
|
+
if (callback) {
|
|
623
|
+
callback();
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
resetState(isStopping ? 'stop' : flushReason);
|
|
630
|
+
if (callback) {
|
|
631
|
+
callback();
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
function ensureSegment() {
|
|
635
|
+
if (state.$rStatus !== SegmentCollectionStatus.WaitingForInitialRecord) {
|
|
636
|
+
return state.$rStatus === SegmentCollectionStatus.SegmentPending;
|
|
637
|
+
}
|
|
638
|
+
var context = getSegmentContext();
|
|
639
|
+
if (!context) {
|
|
640
|
+
return false;
|
|
641
|
+
}
|
|
642
|
+
state = {
|
|
643
|
+
$rStatus: SegmentCollectionStatus.SegmentPending,
|
|
644
|
+
$rSegment: (0, _segment.createSegment)({
|
|
645
|
+
encoder: encoder,
|
|
646
|
+
context: context,
|
|
647
|
+
creationReason: state.$rNextReason
|
|
648
|
+
}),
|
|
649
|
+
$rLocked: state.$rLocked,
|
|
650
|
+
$rLockGeneration: lockedBufferGeneration,
|
|
651
|
+
$rGeneration: activeBaselineGeneration,
|
|
652
|
+
$rHasSnapshot: false,
|
|
653
|
+
$rMandatoryRecoveryHold: mandatoryRecoveryPending,
|
|
654
|
+
$rExpiration: (0, _browserCore.setTimeout)(function () {
|
|
655
|
+
flushSegment('segment_duration_limit');
|
|
656
|
+
}, SEGMENT_DURATION_LIMIT)
|
|
657
|
+
};
|
|
658
|
+
return true;
|
|
659
|
+
}
|
|
660
|
+
function discardEmptyCurrentSegment(reason) {
|
|
661
|
+
if (state.$rStatus === SegmentCollectionStatus.SegmentPending && state.$rSegment.isEmpty()) {
|
|
662
|
+
(0, _browserCore.clearTimeout)(state.$rExpiration);
|
|
663
|
+
resetState(reason);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
function discardCurrentSegment(reason) {
|
|
667
|
+
if (state.$rStatus !== SegmentCollectionStatus.SegmentPending) {
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
var discardedSegment = state.$rSegment;
|
|
671
|
+
var isEmpty = discardedSegment.isEmpty();
|
|
672
|
+
(0, _browserCore.clearTimeout)(state.$rExpiration);
|
|
673
|
+
resetState(reason);
|
|
674
|
+
if (!isEmpty) {
|
|
675
|
+
// The deflate encoder is shared by consecutive segments. Merely
|
|
676
|
+
// forgetting this Segment would leave its already-written bytes in the
|
|
677
|
+
// active stream and prepend them to the replacement baseline. Finalize
|
|
678
|
+
// the stream to reset the encoder, but deliberately ignore its result.
|
|
679
|
+
discardedSegment.$rDiscard(function () {
|
|
680
|
+
// A rejected mandatory Full Snapshot may have marked recovery while
|
|
681
|
+
// encoder writes were still pending. Wake the deferred notification
|
|
682
|
+
// after finish drains that backlog, even though this segment result is
|
|
683
|
+
// intentionally not delivered.
|
|
684
|
+
scheduleReplayResetNotification();
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
function addRecordToCurrentSegment(record, serializedRecordData, ignoreSegmentBytesLimit) {
|
|
689
|
+
var segmentState = state;
|
|
690
|
+
var segment = segmentState.$rSegment;
|
|
691
|
+
var synchronousEncoderError;
|
|
692
|
+
var addResult = segment.addRecord(record, function (encodedBytesCount, error) {
|
|
693
|
+
if (state.$rStatus !== SegmentCollectionStatus.SegmentPending || state.$rSegment !== segment) {
|
|
694
|
+
scheduleReplayResetNotification();
|
|
131
695
|
return;
|
|
132
696
|
}
|
|
133
|
-
if (
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
697
|
+
if (error) {
|
|
698
|
+
synchronousEncoderError = error;
|
|
699
|
+
var isBaselineTransactionFailure = activeBaselineTransaction && activeBaselineTransaction.$rSegment === segment;
|
|
700
|
+
(0, _browserCore.clearTimeout)(state.$rExpiration);
|
|
701
|
+
reportDroppedRecord('encoder_error', 0);
|
|
702
|
+
resetState('encoder_error');
|
|
703
|
+
failBaselineGeneration(segmentState.$rGeneration, 'encoder_error', segmentState.$rHasSnapshot || Boolean(isBaselineTransactionFailure));
|
|
704
|
+
} else if (encodedBytesCount > SEGMENT_BYTES_LIMIT && !segmentState.$rMandatoryRecoveryHold) {
|
|
705
|
+
if (activeBaselineTransaction && activeBaselineTransaction.$rSegment === segment) {
|
|
706
|
+
// Meta + Focus + FullSnapshot is one replay baseline. An encoder
|
|
707
|
+
// callback may run synchronously while those records are being
|
|
708
|
+
// added; flushing after Meta would expose an incomplete baseline
|
|
709
|
+
// and leave the following records without a current segment.
|
|
710
|
+
activeBaselineTransaction.$rExceededSegmentBytesLimit = true;
|
|
711
|
+
} else {
|
|
712
|
+
flushSegment('segment_bytes_limit');
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
scheduleReplayResetNotification();
|
|
716
|
+
}, ignoreSegmentBytesLimit ? undefined : SEGMENT_BYTES_LIMIT, pendingRawBytesLimit, serializedRecordData);
|
|
717
|
+
if (synchronousEncoderError) {
|
|
718
|
+
return {
|
|
719
|
+
status: 'encoder_error',
|
|
720
|
+
error: synchronousEncoderError
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
return addResult;
|
|
724
|
+
}
|
|
725
|
+
function flushCanvasWithRateLimit() {
|
|
726
|
+
var now = (0, _browserCore.dateNow)();
|
|
727
|
+
var timeUntilNextFlush = CANVAS_FLUSH_MIN_INTERVAL - (now - lastCanvasFlushAt);
|
|
728
|
+
if (timeUntilNextFlush <= 0) {
|
|
729
|
+
lastCanvasFlushAt = now;
|
|
730
|
+
flushSegment('canvas_snapshot');
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
if (canvasFlushTimeoutId === undefined) {
|
|
734
|
+
canvasFlushTimeoutId = (0, _browserCore.setTimeout)(function () {
|
|
735
|
+
canvasFlushTimeoutId = undefined;
|
|
736
|
+
lastCanvasFlushAt = (0, _browserCore.dateNow)();
|
|
737
|
+
flushSegment('canvas_snapshot');
|
|
738
|
+
}, timeUntilNextFlush);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
function addRecordWithBaselineGeneration(record, serializedRecordData, ignoreSegmentBytesLimit) {
|
|
742
|
+
var segmentState = state;
|
|
743
|
+
var previousBaselineGeneration = activeBaselineGeneration;
|
|
744
|
+
var previousSegmentBaselineGeneration = segmentState.$rGeneration;
|
|
745
|
+
var previousHasFullSnapshot = segmentState.$rHasSnapshot;
|
|
746
|
+
var fullSnapshotGeneration;
|
|
747
|
+
if (record.type === _types.RecordType.FullSnapshot) {
|
|
748
|
+
var previousActiveBaselineGeneration = activeBaselineGeneration;
|
|
749
|
+
fullSnapshotGeneration = ++nextBaselineGeneration;
|
|
750
|
+
activeBaselineGeneration = fullSnapshotGeneration;
|
|
751
|
+
baselineGenerationStates[fullSnapshotGeneration] = 'pending';
|
|
752
|
+
segmentState.$rGeneration = fullSnapshotGeneration;
|
|
753
|
+
segmentState.$rHasSnapshot = true;
|
|
754
|
+
}
|
|
755
|
+
var result = addRecordToCurrentSegment(record, serializedRecordData, ignoreSegmentBytesLimit);
|
|
756
|
+
if (result.status === 'segment_full' && fullSnapshotGeneration !== undefined) {
|
|
757
|
+
delete baselineGenerationStates[fullSnapshotGeneration];
|
|
758
|
+
activeBaselineGeneration = previousBaselineGeneration;
|
|
759
|
+
segmentState.$rGeneration = previousSegmentBaselineGeneration;
|
|
760
|
+
segmentState.$rHasSnapshot = previousHasFullSnapshot;
|
|
761
|
+
fullSnapshotGeneration = undefined;
|
|
762
|
+
} else if (fullSnapshotGeneration !== undefined) {
|
|
763
|
+
tryCleanupBaselineGeneration(previousActiveBaselineGeneration);
|
|
764
|
+
}
|
|
765
|
+
return {
|
|
766
|
+
$rResult: result,
|
|
767
|
+
$rGeneration: segmentState.$rGeneration
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
function rejectRecordAdmission(wasBackpressured) {
|
|
771
|
+
lastAddRecordWasBackpressured = Boolean(wasBackpressured);
|
|
772
|
+
return false;
|
|
773
|
+
}
|
|
774
|
+
function startFreshBaselineTransactionSegment() {
|
|
775
|
+
if (state.$rStatus === SegmentCollectionStatus.SegmentPending && !state.$rSegment.isEmpty()) {
|
|
776
|
+
if (state.$rMandatoryRecoveryHold) {
|
|
777
|
+
discardCurrentSegment('mandatory_recovery_replaced');
|
|
778
|
+
} else {
|
|
779
|
+
flushSegment('full_snapshot');
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
return ensureSegment();
|
|
783
|
+
}
|
|
784
|
+
function tryAddBaselineTransaction(records, ignoreSegmentBytesLimit) {
|
|
785
|
+
var transaction = {
|
|
786
|
+
$rSegment: state.$rSegment,
|
|
787
|
+
$rExceededSegmentBytesLimit: false
|
|
788
|
+
};
|
|
789
|
+
activeBaselineTransaction = transaction;
|
|
790
|
+
var attempt;
|
|
791
|
+
try {
|
|
792
|
+
for (var index = 0; index < records.length; index += 1) {
|
|
793
|
+
var record = records[index];
|
|
794
|
+
var addResult = addRecordWithBaselineGeneration(record, backpressuredSerializedRecordData.get(record), ignoreSegmentBytesLimit);
|
|
795
|
+
if (addResult.$rResult.status !== 'added') {
|
|
796
|
+
attempt = {
|
|
797
|
+
$rAddResult: addResult,
|
|
798
|
+
$rRecord: record
|
|
799
|
+
};
|
|
800
|
+
break;
|
|
137
801
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
creationReason: state.nextSegmentCreationReason
|
|
144
|
-
}),
|
|
145
|
-
isLocked: state.isLocked,
|
|
146
|
-
expirationTimeoutId: (0, _browserCore.setTimeout)(function () {
|
|
147
|
-
flushSegment('segment_duration_limit');
|
|
148
|
-
}, SEGMENT_DURATION_LIMIT)
|
|
802
|
+
}
|
|
803
|
+
if (!attempt) {
|
|
804
|
+
attempt = {
|
|
805
|
+
$rAddResult: addResult,
|
|
806
|
+
$rRecord: records[records.length - 1]
|
|
149
807
|
};
|
|
150
808
|
}
|
|
151
|
-
|
|
152
|
-
|
|
809
|
+
} finally {
|
|
810
|
+
activeBaselineTransaction = undefined;
|
|
811
|
+
}
|
|
812
|
+
attempt.$rExceededSegmentBytesLimit = transaction.$rExceededSegmentBytesLimit;
|
|
813
|
+
return attempt;
|
|
814
|
+
}
|
|
815
|
+
function rejectBaselineTransaction(records, attempt) {
|
|
816
|
+
var result = attempt.$rAddResult.$rResult;
|
|
817
|
+
var record = attempt.$rRecord;
|
|
818
|
+
records.forEach(function (baselineRecord) {
|
|
819
|
+
backpressuredSerializedRecordData["delete"](baselineRecord);
|
|
820
|
+
});
|
|
821
|
+
if (result.status === 'encoder_error') {
|
|
822
|
+
mandatoryRecoveryPending = false;
|
|
823
|
+
bufferCheckoutPending = false;
|
|
824
|
+
discardCurrentSegment('baseline_transaction_encoder_error');
|
|
825
|
+
return rejectRecordAdmission();
|
|
826
|
+
}
|
|
827
|
+
if (result.status === 'record_too_large') {
|
|
828
|
+
reportDroppedRecord(record.type === _types.RecordType.FullSnapshot ? 'full_snapshot_too_large' : 'record_too_large', result.estimatedBytesCount);
|
|
829
|
+
} else {
|
|
830
|
+
reportDroppedRecord(record.type === _types.RecordType.FullSnapshot ? 'full_snapshot_encoder_backpressure' : 'encoder_backpressure', result.estimatedBytesCount);
|
|
831
|
+
}
|
|
832
|
+
if (record.type === _types.RecordType.FullSnapshot) {
|
|
833
|
+
failBaselineGeneration(attempt.$rAddResult.$rGeneration, result.status === 'record_too_large' ? 'full_snapshot_too_large' : 'full_snapshot_encoder_backpressure', result.status === 'record_too_large');
|
|
834
|
+
}
|
|
835
|
+
mandatoryRecoveryPending = false;
|
|
836
|
+
bufferCheckoutPending = false;
|
|
837
|
+
discardCurrentSegment('baseline_transaction_rejected');
|
|
838
|
+
return rejectRecordAdmission(result.status === 'encoder_backpressure');
|
|
839
|
+
}
|
|
840
|
+
function addBaselineRecords(records) {
|
|
841
|
+
lastAddRecordWasBackpressured = false;
|
|
842
|
+
if (state.$rStatus === SegmentCollectionStatus.Stopped || !records || records.length !== 3 || records[0].type !== _types.RecordType.Meta || records[1].type !== _types.RecordType.Focus || records[2].type !== _types.RecordType.FullSnapshot || !startFreshBaselineTransactionSegment()) {
|
|
843
|
+
return rejectRecordAdmission();
|
|
844
|
+
}
|
|
845
|
+
var attempt = tryAddBaselineTransaction(records, false);
|
|
846
|
+
if (attempt.$rAddResult.$rResult.status === 'segment_full') {
|
|
847
|
+
if (typeof attempt.$rAddResult.$rResult.serializedRecordData === 'string') {
|
|
848
|
+
backpressuredSerializedRecordData.set(attempt.$rRecord, attempt.$rAddResult.$rResult.serializedRecordData);
|
|
849
|
+
}
|
|
850
|
+
// Meta and Focus are the prelude of the Full Snapshot, not independent
|
|
851
|
+
// replay state. Retire this unsent attempt and replay the complete
|
|
852
|
+
// transaction in a fresh segment. Like a Full Snapshot as the first
|
|
853
|
+
// physical record, the retry may exceed the estimated segment target by
|
|
854
|
+
// the small prelude; the finalized payload still goes through the hard
|
|
855
|
+
// SEGMENT_BYTES_LIMIT delivery check.
|
|
856
|
+
discardCurrentSegment('baseline_transaction_retry');
|
|
857
|
+
if (!ensureSegment()) {
|
|
858
|
+
return rejectRecordAdmission();
|
|
859
|
+
}
|
|
860
|
+
attempt = tryAddBaselineTransaction(records, true);
|
|
861
|
+
}
|
|
862
|
+
if (attempt.$rAddResult.$rResult.status !== 'added') {
|
|
863
|
+
return rejectBaselineTransaction(records, attempt);
|
|
864
|
+
}
|
|
865
|
+
records.forEach(function (record) {
|
|
866
|
+
backpressuredSerializedRecordData["delete"](record);
|
|
867
|
+
});
|
|
868
|
+
if (mandatoryRecoveryPending) {
|
|
869
|
+
mandatoryRecoveryPending = false;
|
|
870
|
+
bufferCheckoutPending = false;
|
|
871
|
+
state.$rMandatoryRecoveryHold = false;
|
|
872
|
+
flushSegment('mandatory_full_snapshot');
|
|
873
|
+
} else if (attempt.$rExceededSegmentBytesLimit) {
|
|
874
|
+
flushSegment('segment_bytes_limit');
|
|
875
|
+
}
|
|
876
|
+
return true;
|
|
877
|
+
}
|
|
878
|
+
var segmentCollection = {
|
|
879
|
+
$rAddBaselineRecords: addBaselineRecords,
|
|
880
|
+
addRecord: function addRecord(record) {
|
|
881
|
+
lastAddRecordWasBackpressured = false;
|
|
882
|
+
if (state.$rStatus === SegmentCollectionStatus.Stopped) {
|
|
883
|
+
return rejectRecordAdmission();
|
|
884
|
+
}
|
|
885
|
+
if (bufferCheckoutPending && record.type !== _types.RecordType.FullSnapshot && record.type !== _types.RecordType.Meta && record.type !== _types.RecordType.Focus) {
|
|
886
|
+
return rejectRecordAdmission();
|
|
887
|
+
}
|
|
888
|
+
if (replayResetNeeded && record.type !== _types.RecordType.FullSnapshot && record.type !== _types.RecordType.Meta && record.type !== _types.RecordType.Focus && baselineGenerationStates[activeBaselineGeneration] !== 'pending') {
|
|
889
|
+
return rejectRecordAdmission();
|
|
890
|
+
}
|
|
891
|
+
if (!ensureSegment()) {
|
|
892
|
+
return rejectRecordAdmission();
|
|
893
|
+
}
|
|
894
|
+
var addResult = addRecordWithBaselineGeneration(record, backpressuredSerializedRecordData.get(record));
|
|
895
|
+
var result = addResult.$rResult;
|
|
896
|
+
if (result.status === 'segment_full') {
|
|
897
|
+
var serializedRecordData = result.serializedRecordData;
|
|
898
|
+
if (state.$rMandatoryRecoveryHold) {
|
|
899
|
+
discardCurrentSegment('mandatory_recovery_replaced');
|
|
900
|
+
} else {
|
|
153
901
|
flushSegment('segment_bytes_limit');
|
|
154
902
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
903
|
+
if (!ensureSegment()) {
|
|
904
|
+
return rejectRecordAdmission();
|
|
905
|
+
}
|
|
906
|
+
addResult = addRecordWithBaselineGeneration(record, serializedRecordData);
|
|
907
|
+
result = addResult.$rResult;
|
|
908
|
+
}
|
|
909
|
+
if (result.status === 'record_too_large') {
|
|
910
|
+
backpressuredSerializedRecordData["delete"](record);
|
|
911
|
+
reportDroppedRecord('record_too_large', result.estimatedBytesCount);
|
|
912
|
+
discardEmptyCurrentSegment('record_too_large');
|
|
913
|
+
// Incremental admission fails synchronously, before the recorder
|
|
914
|
+
// publishes any DOM membership carried by the record. Returning false
|
|
915
|
+
// lets it cancel that staged membership, so the existing baseline
|
|
916
|
+
// remains valid and does not need a global reset.
|
|
917
|
+
if (record.type !== _types.RecordType.IncrementalSnapshot) {
|
|
918
|
+
failBaselineGeneration(addResult.$rGeneration, record.type === _types.RecordType.FullSnapshot ? 'full_snapshot_too_large' : 'record_too_large', record.type === _types.RecordType.FullSnapshot);
|
|
919
|
+
}
|
|
920
|
+
if (record.type === _types.RecordType.FullSnapshot && mandatoryRecoveryPending) {
|
|
921
|
+
mandatoryRecoveryPending = false;
|
|
922
|
+
bufferCheckoutPending = false;
|
|
923
|
+
discardCurrentSegment('mandatory_recovery_failed');
|
|
924
|
+
}
|
|
925
|
+
return rejectRecordAdmission();
|
|
158
926
|
}
|
|
927
|
+
if (result.status === 'encoder_backpressure') {
|
|
928
|
+
if (typeof result.serializedRecordData === 'string') {
|
|
929
|
+
backpressuredSerializedRecordData.set(record, result.serializedRecordData);
|
|
930
|
+
}
|
|
931
|
+
reportDroppedRecord('encoder_backpressure', result.estimatedBytesCount);
|
|
932
|
+
if (state.$rSegment.isEmpty()) {
|
|
933
|
+
discardEmptyCurrentSegment('encoder_backpressure');
|
|
934
|
+
} else {
|
|
935
|
+
flushSegment('encoder_backpressure');
|
|
936
|
+
}
|
|
937
|
+
// See the synchronous incremental rejection rationale above. Full
|
|
938
|
+
// snapshots and non-incremental baseline records retain the existing
|
|
939
|
+
// recovery semantics.
|
|
940
|
+
if (record.type !== _types.RecordType.IncrementalSnapshot) {
|
|
941
|
+
failBaselineGeneration(addResult.$rGeneration, record.type === _types.RecordType.FullSnapshot ? 'full_snapshot_encoder_backpressure' : 'encoder_backpressure', false);
|
|
942
|
+
}
|
|
943
|
+
if (record.type === _types.RecordType.FullSnapshot && mandatoryRecoveryPending) {
|
|
944
|
+
mandatoryRecoveryPending = false;
|
|
945
|
+
bufferCheckoutPending = false;
|
|
946
|
+
discardCurrentSegment('mandatory_recovery_failed');
|
|
947
|
+
}
|
|
948
|
+
return rejectRecordAdmission(true);
|
|
949
|
+
}
|
|
950
|
+
backpressuredSerializedRecordData["delete"](record);
|
|
951
|
+
if (result.status === 'encoder_error') {
|
|
952
|
+
if (record.type === _types.RecordType.FullSnapshot && mandatoryRecoveryPending) {
|
|
953
|
+
mandatoryRecoveryPending = false;
|
|
954
|
+
bufferCheckoutPending = false;
|
|
955
|
+
discardCurrentSegment('mandatory_recovery_failed');
|
|
956
|
+
}
|
|
957
|
+
return rejectRecordAdmission();
|
|
958
|
+
}
|
|
959
|
+
if (record.type === _types.RecordType.FullSnapshot && mandatoryRecoveryPending) {
|
|
960
|
+
mandatoryRecoveryPending = false;
|
|
961
|
+
bufferCheckoutPending = false;
|
|
962
|
+
state.$rMandatoryRecoveryHold = false;
|
|
963
|
+
flushSegment('mandatory_full_snapshot');
|
|
964
|
+
}
|
|
965
|
+
if (options.flushCanvasImmediately && isCanvasMutationRecord(record) && state.$rStatus === SegmentCollectionStatus.SegmentPending) {
|
|
966
|
+
flushCanvasWithRateLimit();
|
|
967
|
+
}
|
|
968
|
+
return true;
|
|
969
|
+
},
|
|
970
|
+
$rWasLastAddRecordBackpressured: function $rWasLastAddRecordBackpressured() {
|
|
971
|
+
return lastAddRecordWasBackpressured;
|
|
159
972
|
},
|
|
160
973
|
unlockSegment: function unlockSegment() {
|
|
161
|
-
state
|
|
974
|
+
state.$rLocked = false;
|
|
975
|
+
drainLockedSegments();
|
|
162
976
|
},
|
|
163
977
|
flushBufferSegment: function flushBufferSegment(callback) {
|
|
164
|
-
|
|
978
|
+
if (bufferCheckoutPending) {
|
|
979
|
+
return false;
|
|
980
|
+
}
|
|
981
|
+
bufferCheckoutPending = true;
|
|
982
|
+
lockedBufferGeneration += 1;
|
|
983
|
+
lockedSegments = [];
|
|
984
|
+
var callbackWasInvoked = false;
|
|
985
|
+
flushSegment('buffer_checkout', function () {
|
|
986
|
+
callbackWasInvoked = true;
|
|
987
|
+
beginMandatoryRecovery();
|
|
988
|
+
if (callback) {
|
|
989
|
+
callback();
|
|
990
|
+
}
|
|
991
|
+
});
|
|
992
|
+
// A non-empty segment finishes asynchronously. Enter the hold before
|
|
993
|
+
// application code can enqueue another record or unlock the error
|
|
994
|
+
// session, so no post-checkout incrementals can be sent without the
|
|
995
|
+
// replacement baseline.
|
|
996
|
+
if (!callbackWasInvoked) {
|
|
997
|
+
beginMandatoryRecovery();
|
|
998
|
+
}
|
|
999
|
+
return true;
|
|
165
1000
|
},
|
|
166
1001
|
isLocked: function isLocked() {
|
|
167
|
-
return state
|
|
1002
|
+
return state.$rLocked;
|
|
1003
|
+
},
|
|
1004
|
+
$rBeginMandatoryRecovery: function $rBeginMandatoryRecovery() {
|
|
1005
|
+
beginMandatoryRecovery();
|
|
1006
|
+
},
|
|
1007
|
+
$rDiscardMandatoryRecovery: function $rDiscardMandatoryRecovery() {
|
|
1008
|
+
if (!mandatoryRecoveryPending) {
|
|
1009
|
+
return;
|
|
1010
|
+
}
|
|
1011
|
+
mandatoryRecoveryPending = false;
|
|
1012
|
+
bufferCheckoutPending = false;
|
|
1013
|
+
if (state.$rStatus === SegmentCollectionStatus.SegmentPending && state.$rMandatoryRecoveryHold) {
|
|
1014
|
+
discardCurrentSegment('mandatory_recovery_incomplete');
|
|
1015
|
+
}
|
|
168
1016
|
},
|
|
169
|
-
stop: function stop() {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
1017
|
+
stop: function stop(flushReason) {
|
|
1018
|
+
lockedBufferGeneration += 1;
|
|
1019
|
+
lockedSegments = [];
|
|
1020
|
+
bufferCheckoutPending = false;
|
|
1021
|
+
clearCanvasFlushTimeout();
|
|
1022
|
+
clearReplayResetNotificationTimeout();
|
|
1023
|
+
upgradeSegmentTransportsForPageExit(flushReason);
|
|
1024
|
+
var stopEvent = (0, _browserCore.isPageExitReason)(flushReason) ? {
|
|
1025
|
+
reason: flushReason
|
|
1026
|
+
} : undefined;
|
|
1027
|
+
prepareRecordsBeforePageExit(stopEvent);
|
|
1028
|
+
if (flushReason === _browserCore.PageExitReason.UNLOADING) {
|
|
1029
|
+
flushSegment(flushReason || 'stop');
|
|
1030
|
+
if (flushPendingSegmentEncodingsForUnload(flushReason)) {
|
|
1031
|
+
// A synchronous encoder drain can release admission backpressure.
|
|
1032
|
+
// Ask the still-active recorder for one final mutation pass before
|
|
1033
|
+
// terminally closing the second unload-safe segment.
|
|
1034
|
+
prepareRecordsBeforePageExit(stopEvent);
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
flushSegment(flushReason || 'stop', undefined, true);
|
|
1038
|
+
// Normal stop/session renewal must not force a potentially large worker
|
|
1039
|
+
// backlog onto the main thread or apply the unload delivery budget. The
|
|
1040
|
+
// encoder queues a reset after each finish, so a restarted recorder can
|
|
1041
|
+
// append a new generation while these old results complete in order.
|
|
1042
|
+
// Only a real unload needs the bounded synchronous drain.
|
|
1043
|
+
flushPendingSegmentEncodingsForUnload(flushReason);
|
|
1044
|
+
unsubscribeLifecycle();
|
|
173
1045
|
}
|
|
174
1046
|
};
|
|
1047
|
+
if (false) {
|
|
1048
|
+
segmentCollection.getBaselineGenerationStateCountForDebug = function () {
|
|
1049
|
+
return Object.keys(baselineGenerationStates).length;
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
1052
|
+
return segmentCollection;
|
|
1053
|
+
function beginMandatoryRecovery() {
|
|
1054
|
+
mandatoryRecoveryPending = true;
|
|
1055
|
+
if (state.$rStatus === SegmentCollectionStatus.SegmentPending) {
|
|
1056
|
+
state.$rMandatoryRecoveryHold = true;
|
|
1057
|
+
(0, _browserCore.clearTimeout)(state.$rExpiration);
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
175
1060
|
}
|
|
176
1061
|
function isCanvasMutationRecord(record) {
|
|
177
1062
|
return record && record.type === _types.RecordType.IncrementalSnapshot && record.data && record.data.source === _types.IncrementalSource.CanvasMutation;
|