Forum

User posts HotGoblins
09 November 2016 10:49
Hi,

Like view in a previous post (here), I encounter memory leak with json in Firefox when I use physics on my scene.

For a project, I have many scenes controlled by the same couple of js but I don't need physics for all scenes. I know I don't resolv this problem of memory leak but I would still limit this.

So, I want, in function of the scene load, that the script choose if it use physics or not. To check if I need physics in my scene, I check if a certain object is present in my blender scene, so it's after the loading scene while the choice of the physics must do before this. I think I am obliged to reload my page to apply this choice.

To reload my page with a param, I think I must write a param in the URL. Or have you an other solution ? To check that, I write a code inspiring me to this topic. I have this code :

exports.init = function () {

        var url_params = m_app.get_url_params();
        var adress = window.location;

        if (!url_params)
            adress += "?quality=true";
        
        window.location.replace(adress);

        var use_physics = "false";
        if (url_params && "quality" in url_params)
            use_physics = url_params["quality"];


        m_app.init({
            canvas_container_id: "main_canvas_container",
            callback: init_cb,
            physics_enabled: use_physics,
        });
    }


For the moment, I ignore if the scene needs physics or not, I just want rewrite the URL but I have this error when I use << window.location.replace(adress); >> :
B4W ERROR : Unable to unload data !


To resume, my questions are :
Rewrite URL with param is the best solution ?
My code is it correct ?
What is this error ?

Thanks in advance.
I'm not crazy ! My reality is just different than yours.
28 October 2016 17:30
Hi,

Yes this problem occured to me when I check "Physics" checkbox is enabled.

I hope the problem will be resolved one day anyway because it's problematic
I'm not crazy ! My reality is just different than yours.
18 October 2016 14:45
Merci pour les infos.

J'ai installé Blender 2.78 et le SDK de B4W 16.09.2.
Mon b4w.min.js date maintenant de cette version donc du 03/10/16.

J'ai refais la même manip, nouveau cube + export json et j'ai toujours pareil.

Non je n'ai jamais installé l'addon, seulement le sdk.
Mais je n'utilise jamais le project manager, je reprend seulement le b4w.min.js, l'uranium.js(+.mem) pour ma physique et je créé moi même les fichiers html, css et js.

Par contre j'utilise cette fonction pour afficher un preloader mais je ne pense pas que j'utilise le webplayer pour autant.

De ton côté, as-tu déjà fait fonctionner un export json sans qu'il pose soucis sur firefox comme ça. As-tu un exemple ?

[Edit]
En décochant "Enable physics" dans le .blend, je peux donc supprimer mes uraniums. Je refais un export json et là il n'y a plus de fuite mémoire. Ca viendrais donc de la physique ?
I'm not crazy ! My reality is just different than yours.
18 October 2016 11:06
J'utilise Win7, 64 bits, Firefox 49.0.1, Blender 2.77a, B4W CE 16.08.

J'ai recréé une scène, donc le cube d'origine, export json + ton html, j'ai encore ce problème de mémoire qui ne cesse d'augmenter.
Je te met le dossier en pièce jointe pour que tu puisses constater.

Est-ce que le problème ne viendrais pas des autres fichiers : les uranium et .b4w_project et project.py ?
D'ailleurs à quoi servent ces fichiers ?

Je repose également ma question : A quoi reconnait-on que l'on utilise le web player de B4W ?

Merci pour ton aide.
I'm not crazy ! My reality is just different than yours.
17 October 2016 09:53
Donc une réponse est :
Le webPlayer de blend4web fait crasher Firefox au bout d'un certain temps à cause d'un memory leak.
Pour pallier à ça, il faut créer son propre webPlayer.

Pour continuer, Oui j'utilise exactement ce fichier html dans mon appli et j'ai le problème. Tu sembles étonné que j'ai le crash avec ce code. Est ce que j'utilise le webPlayer de B4W à ton avis ? Comment on reconnais qu'on l'utilise ?

Je met mon script main.js censuré si ça peut aider aussi :
"use strict"

// check if module exists
if (b4w.module_check("Main"))
    throw "Failed to register module: Main";

// register the application module
b4w.register("Main", function(exports, require) {

    // import modules used by the app
    var m_app = require("app");
    //...

    // import modules in external files
    var m_movement = require("Movement");
    var m_utilitaire = require("Utilitaire");
    var m_interface = require("Interface");

    //...

    exports.init = function () {
        m_app.init({
            canvas_container_id: "main_canvas_container",
            callback: init_cb,
            physics_enabled: true,
            alpha: true
        });
    }

    function init_cb(canvas_elem, success) {
        if (!success) {
            console.log("b4w init failure");
            return;
        }

        window.addEventListener("resize", on_resize);
        //...

        load();
    }

    function load() {
        var preloader_cont = document.getElementById("preloader_cont");
        preloader_cont.style.visibility = "visible";
        m_data.load("Digibim.json", load_cb, preloader_cb);
    }

    function load_cb(data_id) {
        //...
    }

    function preloader_cb(percentage) {
        var prelod_dynamic_path = document.getElementById("prelod_dynamic_path");
        var percantage_num = prelod_dynamic_path.nextElementSibling;

        prelod_dynamic_path.style.width = percentage + "%";
        percantage_num.innerHTML = percentage + "%";
        if (percentage == 100) {
            var preloader_cont = document.getElementById("preloader_cont");
            preloader_cont.style.visibility = "hidden";
            return;
        }
    }

    function on_resize() {
        m_cont.resize_to_container();
        m_interface.refresh_screen_size();
    }

    //other functions
    //...
});

// import the app module and start the app by calling the init method
b4w.require("Main").init();
I'm not crazy ! My reality is just different than yours.
14 October 2016 11:29
Oh, it's very impressive.
In this case, I don't need to do anything, cool
I'm not crazy ! My reality is just different than yours.
14 October 2016 10:50
Merci Martial, non c'était moi qui n'avait pas compris.
Je vais la faire en français comme ça se sera plus simple pour nous deux.

Sorry english people

Donc si je te comprend bien, pour résoudre le problème il ne faut pas utiliser le web player de B4W.
Il faut donc modifier le fichier html.
Dans ton exemple, tu mets ton script dans le html, c'est seulement ça qu'il faut faire pour changer de webPlayer ?
Je t'avouerai que je ne m'y connais pas beaucoup dans ce domaine, la programmation et le 3D oui mais pas tout ce qui est web.
Le problème, c'est que moi j'utilise 5 scripts js différents et ils sont assez longs. Si je met tout ça dans le html ça va être le bordel. Je te mets mon html courant au cas où ça pourrait aider.

<!DOCTYPE html>
<html>

    <head>
        <title>Digibim</title>
        <meta charset="utf-8">
        <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width" />

        <link rel="stylesheet" href="Digibim.css" type="text/css" />

        <script type="text/javascript" src="..\Appli\b4w.min.js"></script>
        <script type="text/javascript" src="..\Appli\script\Interface.js"></script>
	<script type="text/javascript" src="..\Appli\script\Utilitaire.js"></script>
	<script type="text/javascript" src="..\Appli\script\Movement.js"></script>
        <script type="text/javascript" src="..\Appli\script\Main.js"></script>

    </head>


    <body>

        <div id="main_canvas_container"></div>
		
		<div id="preloader_cont">
			<div id="prelod_static_path">
				<div id="prelod_dynamic_path"></div>
				<span>0%</span>
			</div>
		</div>	

    </body>

</html>
I'm not crazy ! My reality is just different than yours.
14 October 2016 09:38
Not for me.

My custom export in json are the same problem
I'm not crazy ! My reality is just different than yours.
13 October 2016 14:43
sorry, I don't know how to delete this second post
I'm not crazy ! My reality is just different than yours.
13 October 2016 14:40
Hi,
I noticed a bug.

When I (and other colleagues) execute an app create with .json export, Firefox crash after 8-10min.
To identify this problem, I have create a new app with Project Manager.
In .html, no problem. In Chrome and Explorer, no problem.
As it's a new project with only cube, the problem doesn't come to my script.

To illustrate this bug :
At launch, the "Plugin Container for Firefox" starts at 200 000 K of memory but it grow up in time !
At the end, it reaches more than 3 000 000 K !! and Firefox crash.



I'm not crazy ! My reality is just different than yours.