aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/api
diff options
context:
space:
mode:
authorstephan <stephan@noemail.net>2022-10-04 00:54:00 +0000
committerstephan <stephan@noemail.net>2022-10-04 00:54:00 +0000
commit3c272ba380084e48e583c13898aeac1aa3cc4f86 (patch)
tree2c3b43f9f9325dc1d66c3e1f2d6c601d37ca1fed /ext/wasm/api
parent88838f6b95fc468e7df46d0cb223dace60cf6f79 (diff)
downloadsqlite-3c272ba380084e48e583c13898aeac1aa3cc4f86.tar.gz
sqlite-3c272ba380084e48e583c13898aeac1aa3cc4f86.zip
Add a test/debug mechanism to shut down the OPFS async listener so that it can be inspected (it normally can't be because its tight event-listening loop ties up the thread) and then restarted.
FossilOrigin-Name: 7d0bcff4e9b899cd25b393b9f0a02c5dcee2e229f0a0fa01719c7dcd7dcbe7c1
Diffstat (limited to 'ext/wasm/api')
-rw-r--r--ext/wasm/api/sqlite3-api-opfs.js20
1 files changed, 18 insertions, 2 deletions
diff --git a/ext/wasm/api/sqlite3-api-opfs.js b/ext/wasm/api/sqlite3-api-opfs.js
index 42c0e1166..7b85ac06c 100644
--- a/ext/wasm/api/sqlite3-api-opfs.js
+++ b/ext/wasm/api/sqlite3-api-opfs.js
@@ -142,7 +142,7 @@ const installOpfsVfs = function callee(asyncProxyUri = callee.defaultProxyUri){
"\nTotal of",n,"op(s) for",t,
"ms (incl. "+w+" ms of waiting on the async side)");
console.log("Serialization metrics:",metrics.s11n);
- opRun('async-metrics');
+ W.postMessage({type:'opfs-async-metrics'});
},
reset: function(){
let k;
@@ -285,7 +285,8 @@ const installOpfsVfs = function callee(asyncProxyUri = callee.defaultProxyUri){
state.opIds.xTruncate = i++;
state.opIds.xWrite = i++;
state.opIds.mkdir = i++;
- state.opIds['async-metrics'] = i++;
+ state.opIds['opfs-async-metrics'] = i++;
+ state.opIds['opfs-async-shutdown'] = i++;
state.sabOP = new SharedArrayBuffer(i * 4/*sizeof int32*/);
opfsUtil.metrics.reset();
}
@@ -888,6 +889,20 @@ const installOpfsVfs = function callee(asyncProxyUri = callee.defaultProxyUri){
);
};
+ /**
+ Only for test/development use.
+ */
+ opfsUtil.debug = {
+ asyncShutdown: ()=>{
+ warn("Shutting down OPFS async listener. OPFS will no longer work.");
+ opRun('opfs-async-shutdown');
+ },
+ asyncRestart: ()=>{
+ warn("Attempting to restart OPFS async listener. Might work, might not.");
+ W.postMessage({type: 'opfs-async-restart'});
+ }
+ };
+
//TODO to support fiddle db upload:
//opfsUtil.createFile = function(absName, content=undefined){...}
@@ -1028,6 +1043,7 @@ const installOpfsVfs = function callee(asyncProxyUri = callee.defaultProxyUri){
break;
}
};
+
})/*thePromise*/;
return thePromise;
}/*installOpfsVfs()*/;