Jump to content

Optimize Performance on Static PIXI Sprite/Containers


maumd
 Share

Recommended Posts

Hello, I'm a developer at Colonist.io and we are looking to increase the game performance on all devices. To test performance, we run multiple instances to force our computer to work harder.

We noticed that one of the biggest FPS word is the Player Container View which only displays content and it has zero animations. When we hide it using PIXI.JS Developer Tools, FPS increase by ~15 on all instances. We already started optimizing by using `cacheAsBitmap`, however it is not possible to cache the whole container as content inside it changes from time to time (text and colors). We tried enabling `cacheAsBitmap` by default, disable it on every change, and enable it again after that, however it has some issues such as not being able to listen for `onClick` and a small but noticeable jitter.

 

Some notes:

- We are using PIXI.JS 5.3.12

- Spector.js only reports 9 draws

- Attached is the structure of every single player container and what we are optimizing

- We are aware that all GUI should be made with raw HTML and CSS but we want that to be our last resort. 

- Sprites are loaded and rendered with the following logic:

// This gets run before the game starts
export function loadImages() {
	for(const img of getImagesToPreload()) {
		const imgPath: string = UIImagePathController.getImagePath(img.name + img.extension)
        PIXI.Loader.shared.add(img.name, imgPath, {crossOrigin: true})
    }

    PIXI.Loader.shared.onProgress.add(loadProgressHandler)
    PIXI.Loader.shared.load(assetsFinishedLoading)
}

// This is an example of how we load a texture 
static getTextureForCard(cardEnum: CardEnum): PIXI.Texture {
  const cardData = CardDataController.getCardDataForCard(cardEnum)
  if(cardData == undefined) {
    logError('getTextureForCard', [cardEnum])
    return PIXI.Loader.shared.resources.card_rescardback.texture
  }

  return PIXI.Loader.shared.resources[cardData.imageFileName].texture
}

 

I don't really know what the approach here should be. Any help is appreciated.

 

Thanks!

 

CleanShot 2023-09-26 at 18.35.20@2x.png

2023339546_CleanShot2023-09-26at18_35.29@2x.png

CleanShot 2023-09-26 at 18.34.53@2x.png

CleanShot 2023-09-26 at 19.21.23@2x.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...