Auto Runner constant stuttering

  • I am having trouble with an auto-runner I’ve been working on, and I was hoping that someone here might be able to help. I have background layers, coins, and enemies moving in one direction with bullet behavior, passing by a running-in-place player character to simulate movement. The framerate is almost constantly 60, with the occasional brief drop to 59, but I still get annoying stutters. There’s no clear logic behind when the stutters occur, either: I’ve stripped the game down to its most basic, with minimal code and almost no memory usage, yet there they are. I don't think that it's my code or my assets to blame because I see the exact same lurching effect take place in the auto-runner template that came with Construct, like a brief jank or screen tear.

    I have all of my sprites pre-loaded into memory, and I’ve experienced the problem on multiple systems/browsers. It’s obvious (and annoying) enough that I’m worried that it’ll be game ruining if I try to sell it anyplace. Otherwise I am very pleased with Construct 2 and 3. If anyone has ideas about how to eliminate it, I’d be grateful.

  • Jank has been widely discussed in these forums under various guises. I’m sure I started a few threads myself.

    It used to be many times worse than it is now as far as I can see. Assuming it is not an issue with your code and as long as you have your sprites “preloaded” in the loading layout and preload sounds ticked there is not much more you can do your end. Going framerate independent dosent appear to help either. The issue has never really been fully resolved or even understood as far as I can see. Its possible it is something inherent in the underlying HTML JS tech, but also, if you go to the Chrome issue forums you will see that Chrome are also wrestling with issues around vsync signalling between OS, browser and monitors, especially when there is multi monitor set up. The only things I would say to you that I have noticed is that. 1) Jank is usually only an issue during the first 30 seconds after loading. 2) Is much less prevalent in standalone apps / nwjs packages and 3) There appears to be very much less jank (to almost negligible levels) as the game gets bigger, i.e. more memory / CPU / GPU being used. Sorry not much help but just FYI.

  • I appreciate the reponse. I’ve occasionally wondered if it has anything to do with the bullet behavior and delta time, since the framerate drop itself is so miniscule (60 to 59 and back), but just enough to cause things to skip forward in order to catch up. The game itself runs extremely smooth except for those random hitches. I tried using minimum framerate or timescaling to smooth out any delta time issues, but the stuttering still occurred, albeit less frequently. I also attempted (and failed) to come up with an alternative way to move things smoothly that wouldn’t be so visibly affected during delta-time hiccups.

    I’m hoping that I can find some way to minimize or even bypass whatever aspect is causing trouble.

  • You can use FireFox to look what the cause of the stuttering is. Start your game and press shift+f5 (performance tools) and start the recording, after a short time stop the recording. Now you can see if you have frame drops.

    Mostly it's the garbage collector.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • RaptorWingGames

    I had jank with auto-runners before too, including the C2 example one, and found that replacing Bullet behaviour with lerp based movement using dt made it smoother.

    Set X to lerp(Self.X, Self.X - Speed, dt)

    Here's an example C2 capx

  • Thanks a lot. I’ll look into garbage collection and try implementing lerp to see if there’s an improvement.

  • RaptorWingGames

    Woah..... hold your ....horses.... I take it back.....

    Now that I am trying to get back into my project from after Christmas, last night I noticed that there is indeed a whole new world of jank, at least in preview mode. in chrome

    My project has multiple layers of fast scrolling background so jank is very noticeable.

    And now in preview mode the jank is serious and continual and pretty much makes the preview mode unplayable.

    on an (surface pro 4 i5 with integrated graphics) FPS is still mostly 60, CPU is hovering around 40pc render time if I recall is around 0.3 s/s but the jank is very bad.

    Before Christmas there was a little jank in the same project (on preview), generally at the start but not anything like this.

    Please note this is in preview mode only, on chrome.

    an nwjs package of the same game has pretty much negligible jank and I am currently unable to test web hosted version.

    (i am not bothering with apk for now as my game is not optimized for mobile )

    but there definitely has been a change over Christmas which has effected preview.

    maybe it has something to do with meltdown patch?

    Can anyone else comment on web hosted games?, hopefully it is just preview.

  • V-sync involves very time-sensitive operations (it must prepare a frame in 16ms, otherwise it drops a frame). It's possible that if the OS does some background work, it schedules work away from the game just long enough to drop a frame. I'm pretty sure it varies depending on the system configuration (OS, driver, background work, compositor mode, etc) which makes it hard to reproduce consistently.

    FWIW other engines with native code have similar issues which are similarly hard to pin down (e.g. see this thread), so I don't think this is anything specific to HTML5 or browsers.

  • V-sync involves very time-sensitive operations (it must prepare a frame in 16ms, otherwise it drops a frame). It's possible that if the OS does some background work, it schedules work away from the game just long enough to drop a frame. I'm pretty sure it varies depending on the system configuration (OS, driver, background work, compositor mode, etc) which makes it hard to reproduce consistently.

    FWIW other engines with native code have similar issues which are similarly hard to pin down (e.g. see this thread), so I don't think this is anything specific to HTML5 or browsers.

    Lolz I was reading through those posts and some of them are citing Construct 2 as a shinning example of having no "microstutters".

    the grass is always greener!

    Yes looks like to me that the browser is being hijacked a lot by the OS or other browser operations causing the janks although its a super clean install so Im thinking chrome or ms have updated something recently that is causing much more interruptions during preview..

    Thankfully it doesn't appear to effect nwjs exports

    Although the dream is to see it available in a browser and running smoothly. I may get some hosting package during the week to start testing.

  • Google are still working on improving v-sync accuracy for Chrome too - see this issue which is still open. It's one of their most starred bugs ever.

  • I have been using Construct 3's remote preview mode to test my game on different mobile devices. Reworking the game to minimize garbage collection seems to have solved the issues on PC, but my ultimate goal is mobile, so I'm fine tuning stuff there. What I find interesting is that I get wildly different performance between iPhone and Android, but not in the way I would have expected. My iPhone is a considerably nicer platform, and I know from some of the other games I have on it (XCOM, for instance) that it has a fair amount of horsepower, yet it struggles wretchedly on my little auto runner. Remote Preview can't detect the GPU %, but estimates the CPU usage as averaging in the 80% range. It stutters, ridiculously so, almost to the point of being unplayable. I'm using the default browser to test on, which I assume is Safari.

    My Android, by contrast, is a comparatively cheap little phone I picked up specifically to test lower range mobile. There's the occasional noticeable hitch, but by and large it runs much smoother. The GPU rating appears on the preview and the CPU usage is way down. I know there are a lot of variables to factor in, but the performance difference still floored me, especially given that the iPhone is, technically speaking, the more powerful piece of hardware. Android is my main focus anyway, since I don't have a Mac to compile on, but still. I'd like to iron out those last little Android slowdowns if I can, but I was just surprised by how it all turned out.

  • Right so I tested a few things

    my in work game on my surface pro i5 8gb (they have integrated graphics)

    (note. already established chrome janky during preview)

    1) uploaded as HTML to a free hosting site.

    a) on chrome (hosted , not previewed)

    NICE - minimal jank to the point where I would not care about it. there was a little stuttering when my open project in another tab went to auto save but other than im impressed.

    b) on edge .......(hosted and previewed)

    AWFUL AWFUL OMG 24 FPS janking and stuttering all over the shop

    2) packed up nwjs

    VERY SMOOTH, fixed 60 fps all they way , 1 tini jank a minute maybe but almost unnoticeable.

    So Ashley I think, the return of the janking is just in C3 preview, probably an effect of running the editor and preview in the same browser and my setup/specs.

    but .... and big smelly butt.

    What happened to edge ??????

    Before Christmas , in C2 , my game was performing much better in EDGE than Chrome

    but now , previewed/compiled with C3 is performing very badly in edge like less than 30 fps vs 60 fps chrome , and I pretty much haven't changed anything.

    (I had not tested in edge recently cos C3 in the browser using chrome etc)

    i will check with some older builds to make sure but ....

    any ideas?

  • NetOne Did you get fall creators update? Lot of people complaining about edge after fall creators update. So i doubt it's a C3 issue.

    I'm using SP i5 8g 256 but has not upgraded to FCU yet so if you want i can try performance test to see if i have the same jank in edge.

    I have not not noticed any significant jank when previewing my exported projects in edge.

  • NetOne Did you get fall creators update? Lot of people complaining about edge after fall creators update. So i doubt it's a C3 issue.

    I'm using SP i5 8g 256 but has not upgraded to FCU yet so if you want i can try performance test to see if i have the same jank in edge.

    I have not not noticed any significant jank when previewing my exported projects in edge.

    Yea i am fully up-to date, I just leave auto update do its thing, I have edited my post above, a bit too quick to blame c3!, i forget there are so many variables.

    i will check some old builds with c2 first just to see. but may pm you the game link later see if you get any different results with old edge. dont want to go public with the link as ma geme is in an absolute state also the free hosting has a low download cap.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)