Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16688] Android: Titanium Application events firing after WebView is destroyed

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2014-08-19T23:38:11.000+0000
Affected Version/sRelease 3.2.2
Fix Version/sRelease 3.4.0
ComponentsAndroid
LabelsAPP-767561, module_android, parity, qe-manualtest, supportTeam
ReporterEduardo Gomez
AssigneeSunila
Created2014-03-25T00:28:18.000+0000
Updated2014-08-19T23:38:11.000+0000

Description

Issue description

App is using application level events to communicate with WebViews - by using calls to Ti.App.fireEvent() and Ti.App.addEventListener(). http://docs.appcelerator.com/titanium/3.0/#!/guide/Communication_Between_WebViews_and_Titanium-section-29004919_CommunicationBetweenWebViewsandTitanium-Ti.AppEvents

Steps to reproduce

Grab app.js and logging.html

Click webView "fromWebView" button. Alert shows message.

Click app "fromTitanium" button. Message displayed as expected.

Click "cleanUp" button. Alert fires message.

If you click twice the console message shows TiViewProxy released although function keeps listening event.

_Android monitor_
03-24 18:22:48.531: E/TiViewProxy(12371): (KrollRuntimeThread) [102323,132456] Add called with null child
If you attempt to run it on iOS, event listener isn't available after a second time _Studio output_
[INFO] :   Application started
[INFO] :   TiAppEvents/1.0 (3.2.2.GA.96e9a07)
[DEBUG] :  Loading: /Users/egomez/Library/Application Support/iPhone Simulator/7.1/Applications/CD516444-41E2-4BEE-BACD-ADEE0049F7ED/TiAppEvents.app/_app_props_.json, Resource: _app_props__json
[DEBUG] :  Application booted in 122.496009 ms
[DEBUG] :  New scheme: <NSMutableURLRequest: 0x10883db0> { URL: file:///Users/egomez/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/CD516444-41E2-4BEE-BACD-ADEE0049F7ED/TiAppEvents.app/logging.html }
[DEBUG] :  Loading: /Users/egomez/Library/Application Support/iPhone Simulator/7.1/Applications/CD516444-41E2-4BEE-BACD-ADEE0049F7ED/TiAppEvents.app/logging.html, Resource: logging_html
[DEBUG] :  Firing app event: app:fromTitanium
[ERROR] :  Script Error {
[ERROR] :      backtrace = "#0 () at :0";
[ERROR] :      line = 93;
[ERROR] :      message = "Invalid type passed to function";
[ERROR] :      nativeLocation = "-[TiViewProxy remove:] (TiViewProxy.m:225)";
[ERROR] :      nativeReason = "expected: TiViewProxy, was: NSNull";
[ERROR] :      sourceId = 267172160;
[ERROR] :      sourceURL = "file:///Users/egomez/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/CD516444-41E2-4BEE-BACD-ADEE0049F7ED/TiAppEvents.app/app.js";
[ERROR] :  }
*Cleanup* is called when developer want to dispose of the webview that was added to the view. That last Ti.App.removeEventListener("app:fromTitanium", fromTitanium); fails to work though since the fromTitanium function actually sits in the webView. All we want to do is ensure that the fromTitanium event listener added to the webview is removed once the webview is destroyed.

Attachments

FileDateSize
app.js2014-03-25T00:28:18.000+00001238
logging.html2014-03-25T00:28:18.000+0000349

Comments

  1. Sunila 2014-05-30

  2. Lokesh Choudhary 2014-08-19

    Verified the fix. Titanium Application events do not fire after WebView is destroyed. Closing. Environment: Appc Studio : 3.4.0.201408180158 Ti SDK : 3.4.0.v20140815142514 Mac OSX : 10.8.5 Alloy : 1.5.0-dev CLI - 3.4.0-dev Code Processor: 1.1.1 Nexus 5 - android 4.4.4

JSON Source