flixel icon indicating copy to clipboard operation
flixel copied to clipboard

Large texture entering the camera freezes the game for a few instants

Open Tembac opened this issue 8 years ago • 6 comments
trafficstars

  • Haxe version: 3.4.0
  • Flixel version: 4.3.0
  • OpenFL version: 3.6.1
  • Lime version: 2.9.1
  • Affected targets: windows

Code snippet reproducing the issue:

Uploaded test demo: https://www.dropbox.com/s/v4839sn0xbyx6l1/testBigTexture.rar?dl=0

Video: https://www.dropbox.com/s/dih4lekhem5yh0r/2017-09-06%2017-31-26.flv?dl=0


Observed behavior:

When the sprite that has a large texture enters on screen for the first time the game slows down for a few instants. You can see the stats on the video that shows the framerate drop:

http://puu.sh/xtdb9/57b1415232.jpg

After that, the game keeps working normally.

Expected behavior:

I expect the framerate not to drop the first time the sprite appears on the screen.

Tembac avatar Sep 06 '17 20:09 Tembac

I can't reproduce this at all - on my end, your sample runs smooth as butter in release or debug mode, with both OpenFL 3.6.1 and OpenFL 8. I assume this depends on your system specs - do you have a particularly weak GPU or something? Although mine is far from great as well (AMD Radeon 6850 HD)..

  • Have you tried this on more than one system?
  • What graphics card do you have?
  • Have you made sure to compile a release build? Debug builds can have a fairly severe impact on performance on cpp targets.

Another thing: maybe try vsync="false" in your project.xml. By default it used to be true, but recently this started causing some issues for me (FPS being locked at 30 for no good reason), so I flipped the default in all demos / the project template.

Gama11 avatar Apr 22 '18 13:04 Gama11

My computer is a little old but it is usually fast with games. My specs are: Windows 10 pro Processor: Intel core i7 @ 2.67GHz Ram: 6 Gb Video Card: AMD Radeon HD 7900 series

It's hard to see the frame drop. It is the first time that the object is starting to appear on screen. The following times it will work fine. This is annoying with action games that use HD graphics.

http://puu.sh/A9cun/fa6b5c6832.jpg

This test is with release flixel. Didn't downloaded latest dev yet.

Tembac avatar Apr 23 '18 21:04 Tembac

Probably fetching the asset from disk -- and this would mean it's an OpenFL issue. You can try precaching the asset during a game or scene loading sequence so that it's already in memory when you ask for it.

On Mon, Apr 23, 2018 at 4:13 PM, Tembac [email protected] wrote:

My computer is a little old but it is usually fast with games. My specs are: Windows 10 pro Processor: Intel core i7 @ 2.67GHz Ram: 6 Gb Video Card: AMD Radeon HD 7900 series

It's hard to see the frame drop. It is the first time that the object is starting to appear on screen. The following times it will work fine. This is annoying with action games that use HD graphics.

http://puu.sh/A9cun/fa6b5c6832.jpg

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/HaxeFlixel/flixel/issues/2106#issuecomment-383725015, or mute the thread https://github.com/notifications/unsubscribe-auth/AAtG-CHcquWnm89Bxj7IuaJ0kxBiwl-3ks5trkPdgaJpZM4PO9KA .

-- www.fortressofdoors.com -- Games, Art, Design

larsiusprime avatar Apr 23 '18 21:04 larsiusprime

Thanks! How can I precache assets?

Tembac avatar Apr 23 '18 22:04 Tembac

There are two ways:

When you setup your scene, you can call all your troublesome assets with Assets.getBitmapData(), and pass in the filepath to your asset, and set the cache value to "true". This means the next time flixel tries to load from OpenFL assets, the asset will already be in memory. The second way is you can do: FlxG.bitmap.add() and pass in the path to your asset. That will return a FlxGraphic. You can set the "destroyOnNoUse" property to false. This means that this asset will stay in memory even if no sprite is using it, until the next FlxState change.

Manual asset management is tricky business, though, you must be very careful. By default flixel will clear both the openfl and flixel cache on every state change, and by default will remove assets from memory when no sprites are using them.

On Mon, Apr 23, 2018 at 5:01 PM, Tembac [email protected] wrote:

Thanks! How can I precache assets?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HaxeFlixel/flixel/issues/2106#issuecomment-383737106, or mute the thread https://github.com/notifications/unsubscribe-auth/AAtG-MhL96TcKI11xT6krbftN9S6nniDks5trk8rgaJpZM4PO9KA .

-- www.fortressofdoors.com -- Games, Art, Design

larsiusprime avatar Apr 23 '18 22:04 larsiusprime

Thanks! Seems useful to know, I tried it but It does not solve this problem. The frame drop occurs when the object is entering the screen and not when it is loaded.

Tembac avatar Apr 23 '18 22:04 Tembac