[AC-5286] App crashes when executing evalJS in a webview to change its contents (Ti SDK 6 and Android 4.1.1 only)
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Resolved |
Resolution | Done |
Resolution Date | 2017-12-18T21:12:50.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | n/a |
Reporter | David Benko |
Assignee | Shak Hossain |
Created | 2017-10-16T19:57:15.000+0000 |
Updated | 2017-12-18T21:12:50.000+0000 |
Description
I have a webview that I use evalJS to call a function inside it that changes the content of its html. The app will crash when the javascript inside the webview try to add a paragraph to the html for example.
This bug is only happening on Android 4.1.1. I tried the following SDKs: 6.1.2, 6.2.2 and SDK 6.3.0.v20171016053946 and the bug is happening in all of them.
The line that causes the app to crash is the following line inside the webview:
div.appendChild(paragraph);
Another way to change the content would simply be:
div.innerHTML = '<p>' + text + '</p>'
But this causes crash too.
I also tried to replace evalJS usage with Ti.App.fireEvent and calling SetTextContent inside Ti.App.addEventListener on the webview but the bug still happens.
Code to reproduce:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="content"></div>
<script>
function SetTextContent(text) {
var div = document.getElementById("content");
var paragraph = document.createElement('p');
var textNode = document.createTextNode(text);
paragraph.appendChild(textNode);
if (div.hasChildNodes()) {
div.removeChild(div.childNodes[0]);
}
div.appendChild(paragraph); // This line causes the app to crash. If you comment this line everything works fine.
}
</script>
</body>
</html>
var window = Ti.UI.createWindow();
var webView = Ti.UI.createWebView({
url: '/test.html'
});
window.add(webView);
window.open();
setInterval(function() {
webView.evalJS('SetTextContent(\'testing' + Math.random() + '\')');
}, 3000);
Can anyone verify this issue please?
Hello, Is this only happening on Android 4.1.1? I tried on a different version. wasn't able to reproduce. Can you try on the latest SDK 6.3.0.GA? Thanks.
Hello [~davidbenko], I just wanted to follow up here. Did you manage to follow the instructions provided earlier? Let us know if you still experience any issue. We would be happy to assist you. Best Regards!
Hello, the test case I provided is now indeed working in SDK 6.3.0. However, the webview is still crashing the app with other use cases. I'll try to provide a new code to reproduce.
[~davidbenko] Thanks for your feedback. We will be waiting for your new test code. Best
Hello [~davidbenko], Just passing a followup here.Are you able to get that sorted out? Please let us know if you need more help with this issue. Regards Axway Appcelerator Support
Hello [~davidbenko], Are you still having the issue?Please let us know if you need more help with this issue. Regards Axway Appcelerator Support
Hello, thanks for getting back to me. I'm working on provide an example to reproduce the issue. My app is large and does a buch of interactions with the webview, so I'm trying reducing the problem to a reproducible test case
[~davidbenko],Ok. Thanks for your update. We appreciate it. We will be waiting for your reproducible test case. Best
Hello [~davidbenko], Did you manage to generate the reproducible test case?
Hello Mostafizur, I'm having a hard time trying to reduce to a small test case because the app is large. Anyways we already solved the issue by changing some things in our app so the bug is not happening anymore. You can close the issue