Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7887] Android: Gingerbread 2.3.X: Emulator: WebView evalJS crashes app

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionDuplicate
Resolution Date2012-03-14T16:55:20.000+0000
Affected Version/sRelease 1.7.5, Release 1.8.0.1, Release 2.0.0, Release 1.8.1, Release 1.8.2
Fix Version/sn/a
ComponentsAndroid
Labelsmodule_webview, qe-testadded
ReporterDustin Hyde
AssigneeHieu Pham
Created2012-03-05T15:35:57.000+0000
Updated2013-09-26T17:04:56.000+0000

Description

When the evalJS method of a WebView is called, the app will crash. Log attached. Steps to Reproduce: 1. Run code on 2.3.3 Emulator (WebViewTest project attached). Note: This is a minimal fail case. TIMOB-4885 provides a similar example.
var win = Ti.UI.createWindow();
var webView = Ti.UI.createWebView({ url:'test.html' });

win.add(webView);
win.open();

webView.addEventListener('load', function() {
	webView.evalJS("run()");
});
<!doctype html>
<html>
	<head>
		<title>WebView Test Page</title>
</head>
	<body><h1>WebView Test Page</h1>
	<script type="text/javascript">
			function run() { alert('WebView JS Eval'); };
		</script>
	</body>
</html>
Expected Result: An alert should appear indicating evalJS was successful. Actual Result: Crash.

Attachments

FileDateSize
2.0 Android V8 Emulator 2.3.3 WebView JSEval Crash.txt2012-03-05T15:35:57.000+000015644
WebViewTest.zip2012-03-05T15:35:57.000+00003653158

Comments

  1. Dustin Hyde 2012-03-05

    This behavior is not limited to the evalJS method. Many Titanium API calls from the HTML cause the same crash, such as:
       <!doctype html>
       <html>
       	<head>
       		<title>WebView Test Page</title>
       	</head>
       	<body><h1>WebView Test Page</h1>
       		<script type="text/javascript">
       			Ti.API.info('WebView JS Log Info');
       		</script>
       	</body>
       </html>
       
    or
       <!doctype html>
       <html>
       	<head>
       		<title>WebView Test Page</title>
       	</head>
       	<body><h1>WebView Test Page</h1>
       		<script type="text/javascript">
       			Ti.App.addEventListener('pause', function() {
       			
       			});
       		</script>
       	</body>
       </html>
       
    However, some API calls do not crash the app, such as:
       <!doctype html>
       <html>
       	<head>
       		<title>WebView Test Page</title>
       	</head>
       	<body><h1>WebView Test Page</h1>
       		<script type="text/javascript">
       			Ti.Platform.getOsname();
       			Ti.App.getVersion();
       		</script>
       	</body>
       </html>
       
  2. Hieu Pham 2012-03-14

  3. Dustin Hyde 2013-05-01

    Closing.

JSON Source