About the jerkiness on the movement...

Discussion and feedback on Construct 2

Post » Fri Oct 17, 2014 9:43 am

@skelooth , if C2 wasn't fantastic for the most part, we wouldn't have had this conversation :) It's because it does what it does so good, that what it doesn't do, or fail to do, stand out!

Also, I don't think @Colludium compares apples with oranges with the GTA reference, it's just that it's simply expected from any modern platform to be able to perform some basic staff. And you can't have anything more basic than smooth movement. Imagine a super-duper high end TV with 3D, bells and whistles, perfect blacks, a gazillion shades of gray and colors that make nature shy for her lack of chromatic pallet etc, but every few seconds it skips a frame or two... Would you be able to ignore that? For me it will make watching the movie unbearable, even more because it depicts everything else so great!

@Lunatrap , do you mean Colludium 's example, mine or both? I understand that you've come a long way in your game development, do you encounter this problem in your game?

@Joannesalfa , @Tokinsom , thank you for your input. I myself had reported and unintelligently whined about this in other topics too (that and wanting a dedicated and proper masking system!). I brought this forward now, because I am about to get serious and invest time in game development, while in the past I was just testing, fiddling and learning C2 (I still do). So, something so basic and, in my gamer eyes, distracting, really pulls me off and discourages me to begin with, because I won't accept that my final project will intrinsically have this behavior, regardless of optimization and resource restrains.

Again, I am not trying to flame C2, Scirra or @Ashley. C2 is an amazing software, I am having a great time using it, it's very creative to work and learn with it and in every opportunity I have I spread the word about it in my social and professional environment. That is exactly why I feel so passionate about this issue, it's a deal breaker for me, I just can't accept it as a normal byproduct of HTML5, JavaScript, or whatever technology. It shouldn't exist in an interactive multimedia environment. It breaks the immersion, the experience that otherwise we try very hard to create. So, I need to know, is it something that can be fixed? Will it be fixed?
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Fri Oct 17, 2014 11:52 am

@skelooth, I think part of the problem is one of my expectations compared to yours - I understand that you don't see this staccato game play as a problem, but my expectations are that all game movement from C2's engine should be as smooth as every other html5 game I have seen... Especially the first 20 seconds, when a new player is likely to decide whether or not to quit a game.

I am also just embarking on my first 'proper' and hopefully 'for sale' project - and I made the GTA reference, as @elio0s so eloquently put, because I am not sure I will receive favourable reviews if this cannot be fixed. If more demanding games like GTA play smoothly on the same hardware then my simple platformer will always appear to be at fault. I am already being very careful to avoid the unnecessary creation/destruction of objects mitigate this. However, and especially during the first few seconds of a layout, this problem doesn't seem to be manageable just by being careful with events. I want to avoid having a 15 sec 'loading' splash or showing a message like "some users may occasionally see stuttering game play (just ignore it)".

A couple of Ludum Dares ago I created a platformer and received a couple of comments that the game play was jerky, even though the effect was far less apparent than the demo I linked to earlier in this thread - so it's not just my imagination that this is a problem. I'm expecting to put a lot of hours into my game, but if C2 isn't up to the job then you might be right - maybe I'm trying to use the wrong tool for the job (or maybe I should limit myself to 640x480 or similar with no scale up to full screen). I have tinkered with Unity a little bit over the last couple of years and Unity's 2D optimisations are really quite brilliant; but C2 is far easier to use and I intend to stick with it for long term because I hope that this issue can and will be fixed.

I have no idea how @Ashley has implemented garbage collection in C2 (assuming that is the culprit) and I have no idea how difficult a job it might be to fix. But there is definitely room for improvement and I live in hope, and if you don't ask you never get.
A big fan of JavaScript.
B
76
S
20
G
76
Posts: 2,283
Reputation: 47,550

Post » Fri Oct 17, 2014 12:59 pm

I've looked in to this in the past and I think it's JIT compilation in the Javascript engine. It seems to vary depending on the browser and system. As usual you should test on every browser available to identify issues which are browser-specific. In this case while generally very smooth, sometimes it's a bit janky in Chrome and Firefox. But surprisingly IE11 is rock solid and I basically never see any issues there.

I'd point out this isn't "HTML5's fault", because HTML5 is simply a specification, and it's not like the specification says "browsers must pause for a frame every N frames". It looks like a quirk that Chrome and Firefox are subject to at the moment and I don't think there's any reason it can't be fixed. There's no reason something like this has to be inherent to browser games.

Some random thoughts that I think support the JIT compilation theory:
- we've done loads of work to reduce the garbage created by our engine (specifically to avoid jank like this :P), and it's generally very good at recycling stuff and not needing any significant GC work at runtime. Also modern browser GCs are very good at doing work in lots of little slices instead of having to pause everything while it does work. So GC should not be a significant issue.
- Construct 2's engine is pretty big in terms of lines of code, since it has loads of features and does a lot under the hood. JIT compilers compile on-demand for faster startup. They have various thresholds for compilation like "if a function has been called 100 times, compile it". This means they don't have to compile everything, which likely includes lots of code only ever called once. However it does mean random bits of code end up getting compiled mid-gameplay at non-deterministic times. The size of C2's engine would explain why other smaller engines might not be so affected.
- IE11 apparently has a completely parallel JIT compiler, which would explain why it is so smooth: it's compiling functions in the background while the game continues to run, and just quickly swaps in the finished code when it's done. On the other hand I saw a Google engineer mention that V8 sometimes has to compile synchronously (i.e. causing jank, since it has to stop and wait for it).
- WebGL mode moves more of the rendering logic in to JS code. It usually way outperforms the canvas2d renderer, but since more rendering code is in the JS engine, I guess it could be more subject to jank from compiling that code.
- after a while (15-30 seconds?) the JIT compiler should have basically compiled everything. This explains why it might be janky for a bit at the start, and then get smoother. If you are only seeing problems on startup, try allowing the game to run for a while to "warm up" (so everything which is called a lot is already JIT compiled), and then it should be smoother.

However this is solvable: if Chrome and Firefox are as good at parallelising JIT as IE11 is then it should be fine everywhere. Also simply waiting out the warmup period should make it a lot better. Hopefully most games are just showing a menu or intro credits type sequence at that point. I've also heard the V8 team are working on a new compiler called "TurboFan", which I can't find much information about, but parallel compilation would be an obvious improvement to make for a new compiler.

I had already filed bugs with Chrome and Firefox based on sbperftest since it actually measures jank and dropped frames providing an objective way to measure the problem and provide a yardstick to compare improvements. The bugs I filed don't seem to have gotten much attention yet. So comments and stars on these reports could help them get attention:

Chrome issue 387675
Chrome issue 424563 (which I just filed now to point out IE11 does better than Chrome)
Firefox bug 1028893
Scirra Founder
B
402
S
238
G
89
Posts: 24,613
Reputation: 195,993

Post » Fri Oct 17, 2014 1:04 pm

Heh, filing a bug saying IE11 does better seems to have done the trick - they've already assigned the bug :)
Scirra Founder
B
402
S
238
G
89
Posts: 24,613
Reputation: 195,993

Post » Fri Oct 17, 2014 1:11 pm

Nice work!
A big fan of JavaScript.
B
76
S
20
G
76
Posts: 2,283
Reputation: 47,550

Post » Fri Oct 17, 2014 1:22 pm

Ashley wrote:Heh, filing a bug saying IE11 does better seems to have done the trick - they've already assigned the bug :)


lol xD
ImageImageImageImage
B
158
S
67
G
43
Posts: 2,603
Reputation: 36,003

Post » Fri Oct 17, 2014 2:12 pm

Dear @Colludium , I don't even know what "eloquently" mean! :D

@Ashley , thanks for the thorough reply!

So, if I understand you correctly, for the most part (beside the part that C2 has a big engine that needs to be compiled), the problem lays mostly on the browser's side. On the one hand I am relieved that since this might not be inherent to HTML5 gaming it can be improved-fixed, on the other hand I feel helpless and on the mercy of each browser's developing schedule. I have mixed feelings about this and I am leaning towards the uncomfortable side.

On my system the best viewing experience comes with node-webkit, followed closely by Chrome (38). IE (11) and Firefox (33) fall behind. I don't know how to interpret this, it's just that I have strong feelings against this unwanted behavior and I simply can't accept it for any finished project (well not any project, but certainly not for the ones that have prominent moving graphics). I know that you do your best, on my book this is a priority issue and I hope that the Universe will conspire and address it immediately! (Dear Universe, please, also create out of nothing a masking system that use any Sprite to mask any other Sprite or/and layer. Finally, make C2 have a 2.5d workspace with a "real" camera and z-depth! Oh yes, and a path system! Thank you! Your random blob of molecules, eli0s)

:oops:
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Fri Oct 17, 2014 2:33 pm

@eli0s, LOL!

I too feel a tad helpless and at the mercy of 3rd parties to improve their browsers' GC. I'm going to have to shut off sections of my events and see if there's anything I can do to improve things; I suspect, however, that only time will provide the solution for browser games.... Oddly enough, Node performance is flawless - so why should that be if it's based on Chrome??
A big fan of JavaScript.
B
76
S
20
G
76
Posts: 2,283
Reputation: 47,550

Post » Fri Oct 17, 2014 2:39 pm

Colludium wrote:@eli0s, LOL!

I too feel a tad helpless and at the mercy of 3rd parties to improve their browsers' GC. I'm going to have to shut off sections of my events and see if there's anything I can do to improve things; I suspect, however, that only time will provide the solution for browser games.... Oddly enough, Node performance is flawless - so why should that be if it's based on Chrome??



I have been fiddling with HTML5 and HTML5 canvas for years, and to be honest, adoption of html5 has been extremely fast. It was only a year or two ago that I still had a browser with no webgl support. Mozilla is working on an HTML5 mobile operating system, and all of the big players are banking heavily on HTML5, IE, both Apple and Google are pushing it.

So if it's not supported soon, it will be. V8 is only 6 years old (young for a language runtime/compiler) and things didn't start really moving until chrome started getting significant market share. Net result is we've seen a lot of HTML5 adoption in the past 4 years or so. A *lot*. For websites, for mobile, for apps, for OS's even.
Developing Surolace, the survival role playing space game.

surolace-survival-role-playing-space-game_t116953
B
14
S
4
Posts: 303
Reputation: 1,730

Post » Fri Oct 17, 2014 2:54 pm

Yeah, HTML5 has always been "at the mercy of" each browser maker, but they're generally actually doing an amazing job and improving things really fast. This is just the latest quirk really - wind back 3-4 years and all you had were software-rendered canvas2d with crappy audio support, so things are always getting better. Remember Chrome and Firefox are both on rapid release schedules so if/when this is sorted out, the fix will be out to everyone in short order. And IE with its slower release/update rate doesn't appear to be affected (at least here), so that's less of a worry (if IE was affected then it would definitely be a long outlook to get it fixed).

BTW perfect Vsync is actually pretty hard to achieve - I remember some similar complaints with Construct Classic, which was native C++/DirectX 9 (and note did not have any garbage collection). They were just very small occasional skipped frames. I think ultimately with an OS which is task switching on maybe a 10-20ms frequency, having to very precisely render at 16.7ms intervals to vsync properly, is a high bar to reach, and realistically the odd frame is going to get skipped.
Scirra Founder
B
402
S
238
G
89
Posts: 24,613
Reputation: 195,993

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 5 guests