4ian / GDevelop

🎮 Open-source, cross-platform 2D/3D/multiplayer game engine designed for everyone.
https://gdevelop.io
Other
10.53k stars 840 forks source link

Performance in iOS #3118

Open achubutkin opened 3 years ago

achubutkin commented 3 years ago

Sympthoms

Performance (frames-per-seconds) in iOS immediately drops if you add several sprites (from 5 and higher).

If we add 1-3 tiled sprites, then the performance in iOS and Android (Safari and Chrome) is approximately the same. However, if you add more sprites, from about 10 and more, then the performance in iOS immediately drops.

The Android remains at the same level.

Performance measured in frames-per-seconds:

A little workaround

But, if we apply the following code to all the sprites that we will have static (without animation, filters), then there will be no performance problems in iOS.

    runtimeScene._allInstancesList.forEach(instance => {
        if ((instance.type == "Sprite" || instance.type == "TiledSpriteObject::TiledSprite")) {
            instance.getRendererObject().cacheAsBitmap = true;
        }
    });

Performance measured in frames-per-seconds after the fix:

Environment

iOS 12.5.5 iPhone 6 Plus, full battery, reloaded, cleared memory & background processes Android 10 Mi A2 Lite, full battery, reloaded, cleared memory & background processes

GDevelop 5.0.0-beta117

Screenshots&Demo with sprites and fixes in the attachments.

P.S. This may not be a bug, please consider this as an invitation to discuss the issue. Perhaps I missed something. Thanks!

Demo game

ios-perf-issue.zip

Screenshots

android-perf ios-perf

After applied the fix

ios-fixed-perf

4ian commented 3 years ago

Interesting, are you able to give a quick test in beta 199 that was just released? PixiJS was upgraded in beta 118 and this may have a good effect on this.

achubutkin commented 3 years ago

@4ian Thank you for response. Unfortunately, in the 119th version it remains.

Probably, I`ll should to do open an issue for PixiJS. But then the following research results are unclear:

Next, we have two popular "bunny test"s for PixiJS:

  1. https://www.goodboydigital.com/pixijs/bunnymark/ (oldest, Pixi.js 3.0.0 - WebGL)
  2. https://pixijs.io/bunny-mark/ (newest, PixiJS 6.1.3 - WebGL 2)

Results for test number 1:

Results for test number 2:

At the moment, we are trying to understand what error the engine repeats from test number 2, which results in a drop in FPS in iPhone 6 devices.

As I said above, now we can fix it with setting cacheAsBitmap property as true, but it may be applying only for static tiles in a game.

jeromck commented 2 years ago

Thank you @achubutkin, I used your function in my game and it helped a lot!

FlorentMaillot commented 2 years ago

Hello, thank you very much for this workaround. I experienced the same issue for my game and now it works fine on iOS, like on macOs safari browser.