Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Why my EnterFrame stop on Mac without me tellling it to, and works on Android? — Gideros Forum

Why my EnterFrame stop on Mac without me tellling it to, and works on Android?

edited August 2013 in General questions
Well, I was coding something, and then I tested on Mac, and it worked.

Then I tested it on Android, and it worked.

Then I tested it on Mac again (without changing code, mind you), and it stopped working.

Puzzled, I threw lots of prints... And what happens, is that suddenly one particular EnterFrame event (that DOES NOT have even a remove function for it, since it is supposed to run 100% of the time until the program closes) stop running, while others remain working fine, also only happens on Mac.

How I figure, why?
I make games for children: http://www.kidoteca.com

Comments

  • currently the are only two cases for ENTER_FRAME not to work
    1) ENTER_FRAME event was removed
    2) object to which event was attaches, was garbage collected

    if none of the above applies to you, then it sounds like a bug and in that case, could you show a simple test case when that happens?
  • I wish I could make a test case...

    Because if I could, I would discover why it happens, and would avoid it... :/

    But I will see if GC is killing my stuff.
    I make games for children: http://www.kidoteca.com
  • I was trying to isolate it, and found... this...


    This is NOT the enterframe that stops, but when the if condition on it is reached, the OTHER one stops.

    Thus I did this:

    local function onEnterFrame()
    print("logo enter frame start");
    --[[if canSkip and audioEnded then
    if logoChan then
    logoChan = nil;
    end
    ended = true;
    logoBmp:removeEventListener(Event.ENTER_FRAME, onEnterFrame);
    logoBmp:removeEventListener(Event.TOUCHES_END, onTouchEnd);
    print("logo ended");
    end]]
    print("logo enter frame end");
    end


    And the other enter frame, and this enter frame, remained triggering forever. As I expected.


    Then I did this:


    local function onEnterFrame()
    print("logo enter frame start");
    if canSkip and audioEnded then
    --[[if logoChan then
    logoChan = nil;
    end
    ended = true;
    logoBmp:removeEventListener(Event.ENTER_FRAME, onEnterFrame);
    logoBmp:removeEventListener(Event.TOUCHES_END, onTouchEnd);
    print("logo ended");]]
    end
    print("logo enter frame end");
    end


    I was not expecting anything, yet, when canSkip and audioEnded become true... the other enterframe stops.

    Now, why adding two lines (if canSkip and audioEnded then, end) stops another EnterFrame? WTF!
    I make games for children: http://www.kidoteca.com
  • Further testing:

    local function onEnterFrame()
    print("logo enter frame start");
    if audioEnded then
    end
    print("logo enter frame end");
    end

    breaks stuff.

    local function onEnterFrame()
    print("logo enter frame start");
    if canSkip then
    end
    print("logo enter frame end");
    end

    don't break stuff.



    audioEnded changes:

    --- logo.lua: This file handles the Kidoteca logo
    --- Author: Maurício Gomes
    ---

    local SpriteUtils = require "engine.kidutils.spriteutils"

    local system = {};

    local logoBmp;
    local logoWav;
    local logoChan;
    local logoTexture;
    local canSkip = false;
    local ended = false;
    local audioEnded = false;






    local function onAudioComplete() --triggered by logoChan:addEventListener(Event.COMPLETE, onAudioComplete);
    audioEnded = true;
    end

    function system.Stop()
    if logoChan then
    logoChan = nil;
    audioEnded = true;
    end
    stage:removeChild(logoBmp);
    end


    local function onTouchEnd( event )
    if canSkip then
    if logoChan then
    logoChan:stop();
    logoChan = nil;
    end
    audioEnded = true;
    end
    print("touch end");
    event:stopPropagation();
    end




    Any of these 3 cases, as soon audioEnded is set to true, a unrelated onEnterFrame stops, but only if the audioEnded is checked on that if line I mentioned, and only on Mac (not on Device)
    I make games for children: http://www.kidoteca.com
  • Hmm, what is this other enter frame, is there any specific code there?

    might the problem be, that you have same names for enter frames:

    local function onEnterFrame()

    and

    logoBmp:removeEventListener(Event.ENTER_FRAME, onEnterFrame);

    so when you remove one it actually removes the other one?
  • They have the same name, but are on different files.

    Also, commenting the removeEventListener do not fix the issue. the only way to fix the issue, is NOT put the variable "audioEnded" on the if clause.
    I make games for children: http://www.kidoteca.com
  • yes I understand that, but it seems to be too weird of an issue, so I thought maybe there is some confusion in gideros internally, due to same scopes and same function names
    and maybe something just have been cached or something like that, currently really have no idea what could have happened there
  • tkhnomantkhnoman Member
    edited August 2013
    I have a problem like this from a long time ago,
    The events, movieclip, and timer might stopped, without telling any event completed.

    I might know the reason already, it's because i used to much render process or something like that.
    For example, i have a huge BG (1912 x 970) and other images present on the screen, i tried to tween 4 big images together (1356x 960 in my case) with movieclip, and if i tried another function/animation after that, somehow they would stop in the middle of the process.

    This problem still present even now. Aslo... Might be because something wrong on my code.
  • atilimatilim Maintainer
    edited August 2013
    @speeder_kidoteca, I can recommend adding a line
    stage:addEventListener(Event.ENTER_FRAME, function() collectgarbage() end)
    so that you can catch GC related bugs easily.

    @tkhnoman, Timers, UrlLoaders, SoundChannels and GTweens are never garbage collected while they're running. But this isn't the case for MovieClips. If a running movie clip is removed from the stage then it's eligible for GC (even it's running).
  • @atilim: Hmm... But in my case, they are still on the stage.
  • atilimatilim Maintainer
    @tkhnoman we're talking about Event.COMPLETE event of MovieClip, right? Is there a possibility to isolate the problem? Meanwhile I can look at it also.


  • tkhnomantkhnoman Member
    edited September 2013
    Oh, sorry. It seems that i was wrong.

    I assumed MovieClip is like a tween function when i used it as tweener.

    That is why for example at this code:
    local mc = MovieClip.new{
    {1, 100, sprite, {x = {0, 200, "linear"}}}
    }

    i added sprite to the stage, but not the mc. That's why it was collected...
    When i added mc at stage, it won't be collected.

    Well, thanks for the help, and sorry for the trouble.


    EDIT: When i'm using 2 MovieClip for one sprite, it become a hassle for the parenting stuff... So instead of adding the MovieClip to the stage, i just added it in a global table. It seems working and not being collected.
  • By the way, my bug went away for no reason.

    I changed nothing, and it stopped happening... So I cannot really reproduce it :(
    I make games for children: http://www.kidoteca.com
Sign In or Register to comment.