Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28272] Android: Accelerometer spams warning messages when exiting app

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sRelease 10.0.0
ComponentsAndroid
Labelsaccelerometer, android
ReporterJoshua Quick
AssigneeJoshua Quick
Created2020-12-03T23:49:20.000+0000
Updated2020-12-14T16:15:00.000+0000

Description

*Summary:* After setting up an "update" event listener to Ti.Accelerometer, the app will spam V8 warning messages to the log after backing out of the app. The warning messages won't stop until you relaunch the app or you remove the event listener. *Steps to reproduce:*

Build and run the below code on Android.

Back out of the app.

Notice the log is spammed with the following warning.

[WARN] V8Object: (main) [xx,xx] Runtime disposed, cannot fire event 'update'
function onAccelerometerUpdate(e) {
	Ti.API.info(@@@ (x,y,z) = (${e.x},${e.y},${e.z}));
}
Ti.Accelerometer.addEventListener("update", onAccelerometerUpdate);
*Work-Around:* Remove the event listener before the app exits, which you can do via the Ti.App "close" event.
function onAccelerometerUpdate(e) {
	Ti.API.info(@@@ (x,y,z) = (${e.x},${e.y},${e.z}));
}

Ti.Accelerometer.addEventListener("update", onAccelerometerUpdate);

Ti.App.addEventListener("close", () => {
	Ti.Accelerometer.removeEventListener("update", onAccelerometerUpdate);
});

Comments

  1. Joshua Quick 2020-12-04

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/12318
  2. Samir Mohammed 2020-12-14

    FR Passed, waiting on Jenkins build.
  3. Christopher Williams 2020-12-14

    merged to master for 10.0.0 target

JSON Source