Jump to content

Freezing on new object


erazemnot
 Share

Recommended Posts

Hi everyone,

I'm noticing refresh freezes when showing items (loaded, but with visible set to false). With freeze I mean that although normally the game works with 60fps, when showing new item (loaded but not visible) it takes 300ms to call another render.
My loop is simple and looks like the following:

function render() {  update();  renderer.render( container ); // render stage  requestAnimationFrame( render );}

I logged the render function to output time from the previous render and it returns 300ms when the problematic event occurs. I tested every single line and it came down to a single line:

sprite.visible = true;

This sprite is made visible through keyboard event (when space is pressed) and it is the single line of code being called.
The texture for the sprite is loaded at the beginning by using PIXI.loader with event complete that instantiates the sprite object, closes the loading screen and shows the stage (container object, I'm using pixi 3.0.6). As follows:

PIXI.loader.add("mysprite","sprite.jpg").once('complete',function(){  sprite = new PIXI.Sprite( loader.resources.mysprite.texture );  sprite.position.set( 100, 100 );  container.addChild( sprite );}).load();

So why does it take so much time to render the object, it is loaded just not visible. Is there a workaround, like preloading (am I not doing that already?), I mean, this 300ms freeze is just too noticable.
 
One more thing. It happens only on the first time the sprite is shown, later everything runs smoothly.
 
I am testing with Chrome 43 (I tested the example with Chrome 43, IE11 doesn't seem to have a delay), same thing happens on Android after compiling with CocoonJS.

Thanks.

Link to comment
Share on other sites

I'm running into a similar issue with no solution.

 

I am loading a few dozen new objects at once, so it is more pronounced taking a full 2-5 seconds to display the frame.  When the same action is done again, after all objects on the stage container is destroyed, its instantaneous.

 

I am using spritesheets, if that makes any difference.

Link to comment
Share on other sites

xerver,

 

I apologize for not providing an example earlier.  The project I'm working on cannot be revealed public just yet, so I had to make a separate example to highlight this issue.

 

https://dl.dropboxusercontent.com/u/90649252/pixiexample/index.html

 

This may not be erazemnot's issue, but my problem seems to have a similar symptom.  In the example script, I create a new sprite and add it to the stage container on click, and it uses a spritesheet as a texture.  Admittedly, the spritesheet in the example is pretty large as that mimics the characteristics of my project.

 

Though the spritesheet has been loaded by the assetLoader, there is a noticeable delay between click and object creation.  I assume that since I use several spritesheets in my project, the delay accumulates with each spritesheet to create a 2-5 second delay.

Link to comment
Share on other sites

Totally understand that. I will look into this, thanks!

 

**EDIT**: Added a GitHub issue for this: https://github.com/GoodBoyDigital/pixi.js/issues/1899

 

Thank you for creating a GitHub issue for this.  For the time being I'm going to attempt to see if having single files for most of my sprites will avoid this issue for me.

 

I've just started teasing out all the images from my spritesheet, and so far I have 1046 sprites  <_<

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...