Jump to content

Performance issues when loading several scenes


Temechon
 Share

Recommended Posts

Hello all, 

 

I have some performances issues when importing several scenes from Blender on tablet and some computers (with graphic drivers up to date).

 

I have a page with several images displayed : when an image is displayed, a scene is loaded (like on www.babylonjs.com).

 

I use this method to load a complete scene exported from Blender :

BABYLON.SceneLoader.Load("models/", modelName, engine, function (newScene) { })

In the callback function, I set up my ArcRotate camera, and a new light.

 

My render function is very classical : scene.render() and stats display.

 

My problem is : when I press the "back" button, and load another model (or the same one), I got a big FPS drop, from 60 FPS to 30 FPS (my model has ~20000 vertices)

My handler on the back button takes care to destroy my previous scene : 

 

if (scene) {    scene.dispose();    scene = null;}

Is there something missing in my scene clean up ?

 

Thank you for your help.

 

Link to comment
Share on other sites

I compared your code to mine : It's basically the same. Only the scene is destroyed, and the engine is created each time you laod a new scene.

 

But I think I got it : I have a increasing use of memory.

I load one of my model : 100 Mo used. I load it 5 times more : 190 Mo used. And it keeps going on and on.

 

I am using a single-page navigation model, so my page is never reloaded. Only the scene is stored in a "namespace global" variable to clean it up when creating a new one.

 

I don't understand what's going on...

Link to comment
Share on other sites

I think I found the problem.

 

I have to create an engine each time I select a new scene, because otherwise the canvas element (which is in my selected page) is no more available : each time the "back" button is called, the canvas disappears.

With only one engine, the first scene is displayed correctly, but I have nothing for the next one (canvas.width = canvas.clientWidth = 0)

 

With one engine initialized for each scene (thus for each new one canvas element), I got performances issues. Engine.dispose() is correctly called though...

 

Moreover, I got huge memory issues, and I think it is because of this. Could it be something not correctly done in the engine.dispose() method ? Maybe the webgl context is not released properly ?

 

I will try to create an unit test for this to reproduce it more clearly.

Link to comment
Share on other sites

  • 4 weeks later...

Hi, 

 

I refresh this old topic : I finally got some time to create a unit test available here : https://dl.dropboxusercontent.com/u/17799537/testMemory.zip

 

This is a windows 8.1 application created with visual studio 2013. Please don't pay attention to the application style (it's very ugly).

 

You can load the model available and see by yourself. If you load it several time (click on the tile -> back -> clic on the tile -> back...) you will see that the memory used by the application is increased each time.

The scene and engine clean is in the page groupedItems.js. At each scene and engine unloading, the memory used decreases, but not totally.

 

Thank you for your help.

Link to comment
Share on other sites

Hello David, 

 

Thank you very much for your answer and for your time.

 

With the VS performance tool, I don't have the same result as yours, it's slightly different.This is the result after 10 item load : http://imgur.com/AWesmMk

As you can see, the memory increases (not much, I do agree) but is never released.

 

Moreover, this is the result I have with the Windows tool : http://imgur.com/a/IGryR

The first image is at the very first start of the app.

The second one is after 10 load.

The third one is after more than 20 load.

 

What I don't understand in this is why does the memory consumption increase. I was thinking that after a model load and a back to the home page, the memory would not change.

 

Cheers, 

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