1

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)
Diamond
  • 7,428
  • 22
  • 37
  • Are you using CEF? (is the cef directory under ~/.cn1). Is this related to the `addBrowserNavigationCallback`? If you remove that code does it still freeze? Do you get any browser events e.g. onLoad etc.? Did you try debugging in chrome (assuming CEF is used)? See https://www.codenameone.com/blog/big-changes-jcef.html – Shai Almog Mar 21 '21 at 01:55
  • @ShaiAlmog Yes, I'm using `cef`. The unzipped `cef` folder is under `.codenameone` directory. No, the issue is unrelated to `addBrowserNavigationCallback`, and it freezes regardless of the code. No browser events, so I didn't handle any. http://localhost:8088/ doesn't load in Chrome, I got `ERR_CONNECTION_REFUSED` error. – Diamond Mar 21 '21 at 18:26
  • Are you sure CEF is picked? Do you see anything related to that in the console? – Shai Almog Mar 22 '21 at 03:26
  • @ShaiAlmog I've edited my question to include my console log. – Diamond Mar 22 '21 at 04:28

1 Answers1

2

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.

steve hannah
  • 4,586
  • 11
  • 18
  • Was there an update on Friday? I'm still experiencing the deadlock after updating. `JavaSEJar=175` – Diamond Mar 27 '21 at 12:52