Javascript problem - "crash browser" "infinite loop" timer

Discussion in 'Javascript' started by mkseekprog, Nov 14, 2017.

  1. mkseekprog

    mkseekprog

    Joined:
    Nov 14, 2017
    Messages:
    3
    Likes Received:
    0
    I have a rather thorny js problem. I should say Phaser/javascript problem.
    It was done in the phaser framework. And I have sen this before (but not this extreme). phaser works a lot better offline than online.
    Anyway, have a series of games they are all very similar with only slight differences. But they all crash the browser at the very end. Stranger still, they all work perfectly offline, and even stanger they make it to the end of the game - and then crash. There is a 21 second timer involved and I suspect that. For example:
    Makes it to a reset of the game, both online and off - no problem. Dumps the player back to the beginning.
    //resetGame();
    window.location = "../index.html";
    //end of game - different story - works offline, send player to endgame.html Online, crashes the browser, infinite loop, whatever you want to call it. Player NEVER gets to endgame.html

    if(flagGameover){
    console.log("GOTO GAMEOVER");
    window.location = "../endgame.html";
    }
    }
    }

    }
    Already been through this over and over, went back to the original code, yup, same problem.
    and the coder is no longer around. and I'm not a js expert.
    So what I'm looking for is a quick and dirty solution - abort the js go to the html page.
    It has done everything it was designed to do, except get out of it!
    I've read a few suggestions across the web, such as:
    function FatalError(){ Error.apply(this, arguments); this.name = "FatalError"; }
    ---------------------------
    function javascript_abort()
    --------------------------------
    function clearTimer() {
    clearInterval(intervalTimer);
    }
    -------------------------------
    So, I'm thinking (but don't know how) put a line or two of the above code onto the existing 21 second timer to completely stop it at 21 seconds and 'abort' the js send the user to endgame.html Don't need the js after the 21 seconds at all.

    //Here's the sections dealing with the timer:

    var maxTime = 21; //in SECOND var timerEvent = null;

    //This is where the timer gets added (after a 3 second animation at the beginning of the game)

    console.log("FINISH ANIMATION and ADD TIMER");

    //and this

    timerEvent = game.time.events.add(Phaser.Timer.SECOND * maxTime, moveToEndGame, this);
    },this);
    -----------> and THE END (or supposed to be the end)

    if(!flagGameover && !star.visible && idx_bullet < bullet_array.length)
    initBullet();
    else{
    if(flagGameover){
    console.log("GOTO GAMEOVER");
    window.location = "../endgame.html";
    }
    }
    }

    }
    Anyone done anything like this before? It would be useful to know, save a lot of time and headache. Like I said, the whole thing works until the very end, and it's accomplished everything - except end!
    Thanks
     
    mkseekprog, Nov 14, 2017
    #1
    1. Advertisements

  2. mkseekprog

    mkseekprog

    Joined:
    Nov 14, 2017
    Messages:
    3
    Likes Received:
    0

    I found out what it was.

    It was missing a callover, as in:

    var callGameover = false;
    and......
    if(flagGameover){
    if(callGameover == false){
    callGameover = true;
    console.log("GOTO GAMEOVER");
    window.location = "endgame.html";
    I didn't know that was enough to cause an "infinite loop" but apparently it was. Put the above in and loop gone!
     
    mkseekprog, Nov 19, 2017 at 9:03 AM
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Kelsang Wangchuk

    System.Timers.Timer vs. System.Threading.Timer

    Kelsang Wangchuk, Jul 31, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    1,098
    Kelsang Wangchuk
    Jul 31, 2003
  2. Mehdi
    Replies:
    2
    Views:
    819
    Mehdi
    Dec 23, 2004
  3. ukeu

    Infinite loop problem

    ukeu, Dec 11, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    378
  4. vjay

    Infinite loop problem in linklist

    vjay, Oct 28, 2004, in forum: C Programming
    Replies:
    7
    Views:
    503
    Sastira
    Oct 29, 2004
  5. Allerdyce.John@gmail.com

    loop thru a STL list causes an infinite loop

    Allerdyce.John@gmail.com, Jan 30, 2006, in forum: C++
    Replies:
    5
    Views:
    961
    benben
    Jan 31, 2006
  6. Hukkky

    Server/Client infinite loop problem

    Hukkky, Oct 24, 2008, in forum: C Programming
    Replies:
    3
    Views:
    610
    Keith Thompson
    Oct 25, 2008
  7. mailpitches@email.com

    Kill Javascript infinite loop

    mailpitches@email.com, Aug 6, 2005, in forum: Javascript
    Replies:
    5
    Views:
    345
    Hywel Jenkins
    Aug 7, 2005
  8. alxasa@gmail.com

    I need help writing a smart Javascript infinite loop

    alxasa@gmail.com, Jan 1, 2007, in forum: Javascript
    Replies:
    2
    Views:
    253
Loading...