Search code examples
codenameone

Simulator Freezes With BrowserComponent


I have a BrowserComponent that loads a specific URL.

BrowserComponent browser = new BrowserComponent();
browser.setURL(url);
browser.addBrowserNavigationCallback(url -> {
    ...
    
    return false;
});

This URL redirects to another, with the new page showing a JS alert dialog.

The Simulator freezes without exception or error while attempting to load the page with a dialog, and the only choice left is closing the Sim.

How do I handle a JS dialog in a BrowserComponent?

It will be great if I can dismiss an alert dialog automagically.

My run log:

JCEF Version = 84.4.1.262
CEF Version = 84.4.1
Chromium Version = 84.0.4147.105
initialize on Thread[AWT-EventQueue-0,6,main] with library path ~\.codenameone\cef\lib\win64
Added scheme search://
Added scheme client://
Added scheme cn1stream://

DevTools listening on ws://127.0.0.1:56113/devtools/browser/8a42a5d0-5ad5-4838-9027-ee9737d73370
AppHandler.stateHasChanged: NEW
AppHandler.stateHasChanged: INITIALIZING
AppHandler.stateHasChanged: INITIALIZED
Stream was closed
[EDT] 0:0:18,233 - Codename One revisions: 7dd4e7d08b3442d90959477ee52a5ae8c4361b29

[EDT] 0:0:18,234 - 
[0322/062422.651:INFO:CONSOLE(22)] "Here I am !!!", source: https://cn1app/streams/1 (22)

Solution

  • This issue has been fixed in Git with this commit: https://github.com/codenameone/CodenameOne/commit/c4afc9d428a959e2f8dcf37594bed8ae81e467a2

    It will be included in the next Cn1 update this Friday.