Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12425] Android: WebView: the "load" event is fired twice if setHtml() is called before the window opens

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-02-08T00:08:20.000+0000
Affected Version/sRelease 3.1.0
Fix Version/sRelease 3.1.0, 2013 Sprint 03 API, 2013 Sprint 03
ComponentsAndroid
Labelsn/a
ReporterPing Wang
AssigneePing Wang
Created2013-01-25T19:54:56.000+0000
Updated2014-06-19T12:44:24.000+0000

Description

Steps to reproduce: 1. Run the code attached below. 2. Two alerts show which means the "load" event is fired twice. Expected behavior: load should be only fired once. Note: i) if commenting out webview.setHtml("xxx") but use webview.html="xxx", the "load" event will be only fired once. ii) if running on Galaxy Nexus (4.0.4), a warning shows in the console, like {quote} W/webview ( 2264): java.lang.Throwable: Warning: A WebView method was called on thread 'KrollRuntimeThread'. All WebView methods must be called on the UI thread. Future versions of WebView may not support use on other threads. {quote}
var _window = Ti.UI.createWindow({
	backgroundColor : '#000'
})

var webview = Ti.UI.createWebView({
	top : 0,
	height : 200
});

webview.setHtml('<html><body>test</body></html>');
//webview.html = '<html><body>test</body></html>';

webview.addEventListener('load', function() {
	alert('The webview is loaded!');
});

_window.add(webview);
_window.open(); 

Comments

  1. Ping Wang 2013-01-29

    PR https://github.com/appcelerator/titanium_mobile/pull/3813
  2. Paras Mishra 2013-02-22

    Load event fired once. Verified on : Google Nexus, android :4.1 SDK version: 3.1.0.v20130220200300 CLI version : 3.0.24 OS : MAC OSX 10.7.5 XCode : 4.5.1

JSON Source