[0.20] Timer not working/weird behaviour in preview

It might not be 0.20 related but it started happening after I upgraded.

Whatever the Timer in my app, on repeat or not, here is how it behaves:

  • When I build preview, on the first launch it works OK
  • On all subsequent saves (that trigger a soft relaunch, but no rebuild), each Timer is called as many times as I saved (2, then 3, then 4, etc.) at once, but then it will never reset or repeat.

This is somewhat similar to a bug I reported on LocalNotifications here: https://www.fusetools.com/community/forums/bug_reports/local_notifications_register_once_per_file_save

This is a bit critical to me too because I’m using Timer extensively in an app to allow for transitions to get the time to play. So basically all my transitions are broken :confused:

Hi Cyril, we’re aware of the issue, and it’s in fact annoying me personally too. I’ll see if we can prioritise fixing this soon. Will get back to you later today when I’ve discussed with the team.

I’ve discussed with the team now, but it turns out that this is not a simple fix. This means it can take some time, but it is very high on our priority list.

This should be fixed in the next version of 0.20.

Thanks Anderss!

I’m seeing this exact same bug again.

Oh bummer, that sounds like a regression then. I’ll resserect the old issue and look into this.

Thanks for the speedy heads-up

Hey again Cyril, I’m having an issue reproducing the problem. Would it be possible for you to upload your project to our dropbox so I can work directly on it?

If so please use this https://www.dropbox.com/request/ZgndLtJQm5eGzG9cicGK.

If not please let me know and I can keep digging.

Thanks again

Hi Chris, I uploaded the project. Here is also a video of the issue (I add a different logging message to each save, so you can see more of them are recording):

file

(https://fuseweb.azureedge.net/forum-user-uploads/2016/08/22/QtvWwvYbyN53-legacy-files-9CzZJCJSyKXLtlZo-FhPkNrOVycls4LocH9_ayP54.mov)

You need to login to test the app. Use the email "ariane@gmail.com" and any password. ping me on the Slack channel @cyril if you want me to go over it with you

What is the Fuse version, OS and preview platform you are running on?

I tried to look at your project. I don’t understand why you are using a timer in this case and how it should behave. Could you create a reproducable testcase, as small as possible?

Because when I do this, it behaves exactly as it should:

<JavaScript>
Timer.create(function(){
    console.log('this method is called after 500 ms.');
}, 500, false);
</JavaScript>

Hi Anders, Fuse version is the latest (build 6650), Mac OSX El Capitan (latest) and preview is Local.

I’m using Timers here because at the time (Fuse 0.12) the Navigation transitions wouldn’t work with the button so I was explicitly giving time (hence the Timer) for the transition animations to play. There is also a big loop here that takes ~500ms to complete and was causing a freeze during the animation, etc. I reckon it’s a terrible way to code :slight_smile: but still, the issue persists.

I tried to build a smaller example too, but with simpler examples I cannot reproduce either…

Oh god, after extensive trial and error, the culprit is actually NOT Timer, but addSubscriber!!

Store.loadMatchPage.addSubscriber(prepareFriendList);

Every time I re-save, a Subscriber is added, but the list of previosu subscribers isn’t cleared.

Here is a minimal, self contained app to reproduce. Edit the console.log() and save: a new subscriber function is appended to the list, but the list is not cleared. It must have something to do with how modules are required and communicate with Fuse. It’s a different bug so I’ll open a new thread.

https://fuseweb.azureedge.net/forum-user-uploads/2016/08/22/pKo1IEBQPUv8-legacy-files-Qqsu80DSycC29uLV-Nr6OM9DNl7qyVMhqSVIi23lE.zip

Thanks, nice job cyril :slight_smile: I will get right to it.