Jump to content

Issue with DynamicTexture - drawText?


Xanmia
 Share

Recommended Posts

Not sure if this is object miss use or a bug....

 

When creating multiple dynamicTexures with drawText after around 3000 it crashes webGL, even with disposing of each object and texture right after it was created.

However, you remove the drawText function call and it works fine.

 

I have attached the full html file that I used to reproduce the error as well as provide a correction for work around.  The below is the code in issue:

function testFail(){total++;var background2 = BABYLON.Mesh.CreatePlane("COUNT", 20, scene);background2.material = new BABYLON.StandardMaterial("background", scene);background2.rotation.y = Math.PI;background2.rotation.x = Math.PI/2;background2.rotation.z = Math.PI*1.5;   var backgroundTexture2 = new BABYLON.DynamicTexture("dynamic texture", 512, scene, true);background2.material.diffuseTexture = backgroundTexture2;backgroundTexture2.drawText("+5", null, 350, "bold 325px Segoe UI", "white", "#555555");backgroundTexture2.dispose();background2.dispose();backgroundTexture2=null;background2=null;}    scene.registerBeforeRender(function() {StatusText.innerHTML = "total objects - " + total;//testWorks();testFail();    });

Anyone else run into this???  I was going to put an issue in on github but wanted to validate...

 

 

MemoryIssueWtext.html

Link to comment
Share on other sites

He is referring to an hypothetical attribute on the Material class in babylon js. This attribute is called 'references', and holds the number of mesh this material is linked to.

With such an attribute, it would be easy to remove automatically all materials without any references (material.references === 0), as it is being done for meshes buffers and their clones.

 

Gwenael checked in the source code of Babylon in Github, but this attribute does not exists, thus all material have to be removed manually.

Link to comment
Share on other sites

May I suggest to add an optional paramater?

BABYLON.Material = function (name, scene, notShared) {    this.name = name;    this.id = name;            this._scene = scene;    scene.materials.push(this);    this._canBeShared = !notShared;};

Thus, by default, a material can be shared (current behavior) but you can specify while creating it that you don't want to share it. When a mesh is disposed, we check if its material can be shared. If it can be disposed then we dispose it during disposing the mesh.

 

Maybe this change wouldn't be useful though...

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