From 16c8122254725805be666cf065c590d54d66dfad Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 21 Feb 2021 02:37:11 +0100 Subject: main: Replace hard-coded call IDs with a new counter Looks like this was the answer to the problem of the active tab not reloading consistently. Previously, if I had two instances of an extension loaded in two separate Chrome profiles, the following could happen: 1. Neither profile's active tab reloaded 2. Only one profile's active tab reloaded 3. Both profiles' active tabs reloaded With this change, both profiles' active tabs reload correctly and consistently. --- l/src/main.lisp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'l/src') diff --git a/l/src/main.lisp b/l/src/main.lisp index 9acff14..6f6ed6b 100644 --- a/l/src/main.lisp +++ b/l/src/main.lisp @@ -2,6 +2,7 @@ (defvar *wg* (wait-group:make-wait-group)) (defvar *devtools-root-call-id* (make-instance 'call-id)) +(defvar *devtools-secondary-call-id* (make-instance 'call-id)) (defvar *reloaded-count* 0) (defvar *extension-targets-count* 0) (defvar *last-session-id* "") @@ -109,8 +110,12 @@ ;; Use call ID "1" as this is the first message sent to the attached target. (format t "reloading EXTENSION~%") (setf *last-session-id* session-id) - (websocket-send *client* - (runtime-evaluate-msg 1 session-id "chrome.runtime.reload()")) + (websocket-send + *client* + (runtime-evaluate-msg + (next-call-id *devtools-secondary-call-id*) + session-id + "chrome.runtime.reload()")) (incf *reloaded-count*)) @@ -120,7 +125,10 @@ (format t "reloading NOW~%") (websocket-send *client* - (runtime-evaluate-msg 2 session-id "chrome.tabs.reload()"))) + (runtime-evaluate-msg + (next-call-id *devtools-secondary-call-id*) + session-id + "chrome.tabs.reload()"))) (defun extension-targets (targets) (labels ((extensionp (target) -- cgit v1.2.3