Browse Source

Added a page to test memory leaks

David Catuhe 7 years ago
parent
commit
1086e9bb68

+ 14 - 1
.vscode/launch.json

@@ -158,6 +158,19 @@
             "reAttach": true,
             "reAttach": true,
             "webRoot": "${workspaceRoot}/",
             "webRoot": "${workspaceRoot}/",
             "url": "http://localhost:1338/tests/validation/index.html"
             "url": "http://localhost:1338/tests/validation/index.html"
-        }
+        },
+        {
+            "name": "Launch memory checks (Chrome)",
+            "type": "chrome",
+            "request": "launch",
+            "url": "http://localhost:1338/tests/memoryChecks/index.html",
+            "webRoot": "${workspaceRoot}/",
+            "sourceMaps": true,
+            "preLaunchTask": "run",
+            "userDataDir": "${workspaceRoot}/.tempChromeProfileForDebug",
+            "runtimeArgs": [
+                "--enable-unsafe-es3-apis"
+            ]
+        },        
     ]
     ]
 }
 }

+ 1 - 0
src/Engine/babylon.engine.ts

@@ -5621,6 +5621,7 @@
 
 
             // Unbind
             // Unbind
             this.unbindAllAttributes();
             this.unbindAllAttributes();
+            this._boundUniforms = [];
 
 
             if (this._dummyFramebuffer) {
             if (this._dummyFramebuffer) {
                 this._gl.deleteFramebuffer(this._dummyFramebuffer);
                 this._gl.deleteFramebuffer(this._dummyFramebuffer);

+ 87 - 0
tests/memoryChecks/index.css

@@ -0,0 +1,87 @@
+html, body {
+    width: 100%;
+    height: 100%;
+    padding: 0;
+    margin: 0;
+    background-color: white;
+}
+
+body {
+    background: url("LogoV3.png");    
+    background-position: center center;
+    background-repeat: no-repeat;
+}
+
+.container {
+    width: calc(100% - 50px);
+    display: flex;
+    flex-wrap: wrap;
+    justify-content: center;
+    align-items: center;
+    background: rgba(255, 255, 255, 0.6);
+    margin: auto;
+    margin-top: 10px;
+    margin-bottom: 10px;
+    outline: 2px solid black;
+    max-width: 1000px;   
+}
+
+.containerTitle {
+    width:100%;
+    order: 1;
+    display: flex;
+    background-color: rgba(0, 0, 0, 0.8);
+    height: 50px;
+}
+
+.title {
+    font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
+    font-size: 40px;
+    color: white;
+    text-align: center;
+    margin-left: 20px;
+    order: 1;
+}
+
+.result {
+    color:green;
+    font-size: 30px;
+    order: 2;
+    text-align: center;
+    margin-top: 5px;
+    margin-left: 20px;
+}
+
+.result.failed {
+    color:red;
+}
+
+.waitRing {
+    order: 3;
+    height: 40px;
+    margin-top: 5px;
+    margin-bottom: 5px;
+}
+
+.waitRing.hidden {
+    display: none;
+}
+
+.renderCanvas {
+    position:absolute;
+    transform: translateX(-600px);
+    width: 600px;
+    height: 400px;
+}
+
+.renderImage {
+    order: 1;
+    flex-basis: 50%;
+    width: 50%;
+}
+
+.resultImage {
+    width: 50%;
+    flex-basis: 50%;
+    order: 2;
+}

+ 15 - 0
tests/memoryChecks/index.html

@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+	<title>BabylonJS - Build validation page</title>
+	<link href="index.css" rel="stylesheet" />
+	<script src="../../Tools/DevLoader/BabylonLoader.js"></script>
+	<script src="index.js"></script>
+</head>
+<body>
+	<div>
+		<input type="text" id="sceneName" value="sponza"></input>
+		<button id="run">Run</button>
+	</div>
+</body>
+</html>

+ 32 - 0
tests/memoryChecks/index.js

@@ -0,0 +1,32 @@
+BABYLONDEVTOOLS.Loader.require('../validation/validation.js')
+.load(function() {
+    document.getElementById("run").addEventListener("click", function() {
+        // Loading tests
+        var xhr = new XMLHttpRequest();
+
+        xhr.open("GET", "../validation/config.json", true);
+
+        xhr.addEventListener("load", function () {
+            if (xhr.status === 200) {
+
+                config = JSON.parse(xhr.responseText);
+
+                // Run tests
+                var index = 0;
+
+                var title = document.getElementById("sceneName").value.toLowerCase();
+                for (var index = 0; index < config.tests.length; index++) {
+                    if (config.tests[index].title.toLowerCase() === title) {
+                        break;
+                    }
+                }
+
+                runTest(index, function() {
+                    BABYLON.Engine.LastCreatedEngine.dispose();
+                });
+            }
+        }, false);
+
+        xhr.send();
+    });
+});

+ 1 - 0
tests/validation/validation.js

@@ -124,6 +124,7 @@ function evaluate(test, resultCanvas, result, renderImage, index, waitRing, done
     renderImage.src = renderB64;
     renderImage.src = renderB64;
 
 
     currentScene.dispose();
     currentScene.dispose();
+    currentScene = null;
     engine.setHardwareScalingLevel(1);
     engine.setHardwareScalingLevel(1);
 
 
     done(testRes, renderB64);
     done(testRes, renderB64);