js/foundation/system/system.js in rsence-pre-2.2.0.23 vs js/foundation/system/system.js in rsence-pre-2.2.0.24

- old
+ new

@@ -202,18 +202,36 @@ * +_appId+:: The unique id of the app. * +_forced+:: (Optional) The doesn't wait for the last poll to finish. * **/ killApp: function(_appId, _forced){ - if( !_forced ){ - var _startedWaiting = new Date().getTime(); - while( this.busyApps[ _appId ] === true ) { - /* Waiting for the app to finish its idle loop... */ - if (new Date().getTime() > _startedWaiting + this.maxAppRunTime) { - break; - } - } + this.reniceApp( _appId, -1 ); // prevent new idle calls to the app + if( _forced || ( this.busyApps[ _appId ] === false ) ){ + this._forceKillApp( _appId ); } + else { + /* Waiting for the app to finish its idle loop before killing it */ + var + _startedWaiting = new Date().getTime(), + _this = this, + _timeout = setInterval( + function(){ + if( _this.busyApps[ _appId ] === true ) { + if (new Date().getTime() > _startedWaiting + _this.maxAppRunTime) { + clearTimeout(_timeout); + _this._forceKillApp( _appId ); + } + else { + clearTimeout(_timeout); + _this._forceKillApp( _appId ); + } + } + }, 10 + ); + } + }, + + _forceKillApp: function( _appId ){ this.busyApps[_appId] = true; this.apps[ _appId ].destroyAllViews(); this.apps[ _appId ] = null;