athombv / homey-apps-sdk-issues

This issue tracker is for Homey Developers using the Apps SDK.
21 stars 4 forks source link

animation.registerScreensaver() generates error on firmware 2.4.0 #84

Closed jghaanstra closed 5 years ago

jghaanstra commented 5 years ago

I have an personal app which adds a couple of custom screensavers. Firmware 2.x introduced a racing condition which required a small work around to get the screensavers to register but firmware 2.4.0 seems to have completely broken it. When the app starts and the screensavers are registered the following error is generated from somewhere within Homey core.

/opt/homey-client/system/manager/ManagerApps/bootstrap/sdk/v2/manager/ledring.js:1
(function (exports, require, module, __filename, __dirname) { const Homey=require("homey"),LedringAnimation=Homey.LedringAnimation;class ManagerLedring extends Homey.Manager{__onInit(){this._animations={},["start","stop","finish"].forEach(i=>{this.__client.on(i,(n,t)=>{const e=this._animations[n.animationId];e&&e.emit(i,n.args),t(null)})}),this.__ready()}_onAnimationStart(i,n){return this.__client.emit("start",i,n)}_onAnimationStop(i,n){return this.__client.emit("stop",i,n)}_onAnimationUpdateFrames(i,n,t){return this.__client.emit("updateFrames",{animationId:i,frames:n},t)}_onAnimationFn(i,n,t,e){return this.__client.emit("fn",{animationId:i,method:n,args:t},e)}registerAnimation(i,n){if("function"==typeof n)return Homey.util.callbackAfterPromise(this,this.registerAnimation,arguments);if(!i||i instanceof LedringAnimation!=!0)throw new Error("Invalid animation, must be instance of LedringAnimation.");return this.__client.emit("

TypeError: t is not a function
    at __client.on (/opt/homey-client/system/manager/ManagerApps/bootstrap/sdk/v2/manager/ledring.js:1:331)
    at _eventListeners.filter.forEach.t (/opt/homey-client/system/manager/ManagerApps/bootstrap/sdk/v2/lib/HomeyClient.js:1:1346)
    at Array.forEach (<anonymous>)
    at HomeyClient._onMessage (/opt/homey-client/system/manager/ManagerApps/bootstrap/sdk/v2/lib/HomeyClient.js:1:1323)
    at emitTwo (events.js:126:13)
    at process.emit (events.js:214:7)
    at emit (internal/child_process.js:762:12)
    at _combinedTickCallback (internal/process/next_tick.js:142:11)
    at process._tickCallback (internal/process/next_tick.js:181:9)

The code which can be used te replicate this error can be found here: https://github.com/jghaanstra/jghaanstra.homey/blob/master/app.js#L75

WeeJeWel commented 5 years ago

Fixed in Homey v2.4.1. Thanks for reporting!

WeeJeWel commented 5 years ago

P.S. I've also fixed the race condition :)