From de0f6a2cdd6d574b2af214b7c536efbf6376f861 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 14 Jan 2022 09:07:28 -0500 Subject: [PATCH] Add longest wait time when fetching from storage in support info Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/1865 This may be useful to rule out that the issue is caused by the browser API responding in unduly delayed manner. --- src/js/assets.js | 7 +++++++ src/js/background.js | 1 + 2 files changed, 8 insertions(+) diff --git a/src/js/assets.js b/src/js/assets.js index 3394e8a82..fa327d52f 100644 --- a/src/js/assets.js +++ b/src/js/assets.js @@ -538,6 +538,7 @@ const saveAssetCacheRegistry = (( ) => { })(); const assetCacheRead = async function(assetKey, updateReadTime = false) { + const t0 = Date.now(); const internalKey = `cache/${assetKey}`; const reportBack = function(content) { @@ -551,6 +552,12 @@ const assetCacheRead = async function(assetKey, updateReadTime = false) { getAssetCacheRegistry(), cacheStorage.get(internalKey), ]); + + µb.supportStats.maxAssetCacheWait = Math.max( + Date.now() - t0, + parseInt(µb.supportStats.maxAssetCacheWait, 10) + ) + ' ms'; + if ( bin instanceof Object === false || bin.hasOwnProperty(internalKey) === false diff --git a/src/js/background.js b/src/js/background.js index 5c9d95abe..225b55ae9 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -215,6 +215,7 @@ const µBlock = { // jshint ignore:line supportStats: { allReadyAfter: '', + maxAssetCacheWait: '0 ms', }, pageStores: new Map(),