[TIMOB-28272] Android: Accelerometer spams warning messages when exiting app
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | Release 10.0.0 |
Components | Android |
Labels | accelerometer, android |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2020-12-03T23:49:20.000+0000 |
Updated | 2020-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);
});
PR (master): https://github.com/appcelerator/titanium_mobile/pull/12318
FR Passed, waiting on Jenkins build.
merged to master for 10.0.0 target