Hi Guilherme, Interesting issue. I haven't seen this one very often.
Can you run a quick browser-side diagnostic from the WebRTC popup itself?
open DevTools in the popup window, go to Console, paste the script below, press Enter, and then reproduce the issue while the console is open.
If Chrome blocks the paste, type:
allow pasting
press Enter, and paste the script again.
(function () {
console.log("DEBUG START - Genesys WebRTC Popup");
const results = {
beforeUnload: false,
unload: false,
pageHide: false,
windowClosed: false,
openerLost: false,
navigationDetected: false,
messages: []
};
// Monitor beforeunload
window.addEventListener("beforeunload", function () {
results.beforeUnload = true;
console.log("EVENT: beforeunload triggered");
console.trace("STACK TRACE");
});
// Monitor unload
window.addEventListener("unload", function () {
results.unload = true;
console.log("EVENT: unload triggered");
});
// Monitor pagehide
window.addEventListener("pagehide", function () {
results.pageHide = true;
console.log("EVENT: pagehide triggered");
});
// Intercept window.close
const originalClose = window.close;
window.close = function () {
results.windowClosed = true;
console.log("EVENT: window.close() invoked");
debugger;
return originalClose.apply(this, arguments);
};
// Monitor window.opener
const openerInterval = setInterval(() => {
if (window.opener === null) {
results.openerLost = true;
console.log("EVENT: window.opener lost (parent reference lost)");
clearInterval(openerInterval);
}
}, 500);
// Capture postMessage events
window.addEventListener("message", function (event) {
console.log("EVENT: postMessage received", event.data);
results.messages.push(event.data);
});
// Detect navigation / redirect
let initialHref = window.location.href;
setInterval(() => {
if (window.location.href !== initialHref) {
results.navigationDetected = true;
console.log("EVENT: navigation detected", window.location.href);
}
}, 500);
// Final output
setTimeout(() => {
console.log("FINAL RESULT:");
console.table(results);
console.log("DIAGNOSTIC:");
if (results.windowClosed) {
console.log("CAUSE: window.close() explicitly invoked by script (OpenCTI or adapter)");
} else if (results.openerLost) {
console.log("CAUSE: parent window reference lost (Salesforce Lightning re-render or lifecycle)");
} else if (results.navigationDetected) {
console.log("CAUSE: navigation or redirect detected (possible SSO or reinitialization)");
} else if (results.beforeUnload) {
console.log("CAUSE: external unload event (likely container/lifecycle behavior)");
} else {
console.log("CAUSE: not clear - need to dig deeper into OpenCTI or custom scripts");
}
}, 8000);
})();
How to read the result:
- windowClosed = true
Something is explicitly calling window.close(), possibly the OpenCTI layer, adapter, or custom script.
- openerLost = true
The popup lost its parent window reference. This may happen during Salesforce Lightning re-rendering or softphone reinitialization.
- navigationDetected = true
The popup was redirected or reloaded. This could point to SSO/session refresh or iframe/app reinitialization.
- only beforeUnload = true
The popup is being unloaded by the browser/container lifecycle, not necessarily by an explicit close call.
- no clear signal
Then we should look deeper into OpenCTI events, Salesforce softphone lifecycle, browser console errors, and any custom scripts.