Closed shannah closed 7 years ago
I too have experienced several crashes using the WebBrowser component on a Windows Mobile Phone. Dump files available on request.
Even when it does not crash, nothing is displayed.
Sample program that should display HTML output. Works in simulator, empty screen on device.
`package com.mycompany.myapp;
import com.codename1.components.ToastBar; import com.codename1.components.WebBrowser; import com.codename1.ui.AutoCompleteTextField; import com.codename1.ui.Button; import com.codename1.ui.Display; import com.codename1.ui.Form; import com.codename1.ui.Dialog; import com.codename1.ui.FontImage; import com.codename1.ui.Label; import com.codename1.ui.spinner.Picker; import com.codename1.ui.plaf.UIManager; import com.codename1.ui.util.Resources; import com.codename1.io.Log; import com.codename1.ui.Command; import com.codename1.ui.Toolbar; import com.codename1.ui.events.ActionEvent; import com.codename1.ui.events.ActionListener; import com.codename1.ui.layouts.BorderLayout; import java.io.IOException;
/**
of building native mobile applications using Java. */ public class MyApplication implements ActionListener {
private Form current; private Resources theme; private Command _backCommand;
public void init(Object context) { theme = UIManager.initFirstTheme("/theme");
// Enable Toolbar on all Forms by default
Toolbar.setGlobalToolbar(true);
// Pro only feature, uncomment if you have a pro subscription
// Log.bindCrashProtection(true);
}
public void start() { if(current != null){ current.show(); return; }
String html = "<html><body>" +
"<center><b>Sample Application</b></center>" +
"<br/>Line 1" +
"<br/>Line 2" +
"<br/><font color=\"#ff0000\">Line 3</font>" +
"<br/>Line 4" +
"<br/>Line 5" +
"</body></html>";
Form aboutForm = new Form("Sample App");
aboutForm.setScrollable(false);
aboutForm.setLayout(new BorderLayout());
_backCommand = new Command("Back");
aboutForm.setBackCommand(_backCommand);
aboutForm.addCommandListener(this);
WebBrowser aboutBrowser = new WebBrowser();
aboutBrowser.setPage(html, null);
aboutForm.addComponent(BorderLayout.CENTER, aboutBrowser);
aboutForm.show();
}
public void stop() { current = Display.getInstance().getCurrent(); if(current instanceof Dialog) { ((Dialog)current).dispose(); current = Display.getInstance().getCurrent(); } }
public void destroy() { }
public void actionPerformed(ActionEvent actionEvent) { Command command = actionEvent.getCommand();
if (command == _backCommand) {
stop();
Display.getInstance().exitApplication();
return;
}
} } `
This is still not working for me. there were two issues originally reported. Displaying a web page could crash the app and if it did not crash, the content was blank.
I am not getting anymore crashes but I am not betting any HTML content either. My above sample code reproduces the problem. Run it on a Windows Mobile device and it should display several lines of HTML output. All I get is a blank screen.
Just got the Friday library update and this is still an issue.
This wasn't included in the update this week because I am working on other larger changes with the WebBrowser component.
In the Kitchen Sink demo, the web browser crashes the application. The crash occurs when generating the peer image.
I have narrowed it down to this line:
https://github.com/codenameone/CodenameOne/blob/master/Ports/UWP/VSProjectTemplate/UWPApp/src/com/codename1/impl/SilverlightPeer.cs#L135
And it appears to happen because the webview visibility is set to Collapsed. Setting it to visible fixes the issue, however, for some reason, I still don't see any web view content in the kitchen sink demo. So requires further investigation.