Opening of multiple .love files

Create issue
Issue #104 resolved
Martin Felis repo owner created an issue

Opening a single .love file works, however when opening another .love file simply opens the activity of the previous .love file and restarts that instead of the new one.

Comments (14)

  1. Karthik T

    Looks good. Needs more testing and a bug which is probably my side, but seems to work with multiple games with a cursory test. Thanks !!

  2. Martin Felis reporter

    This my the answer to

    "Since you are now using a static activity, I commented out // mSingleton = null; . Does this seem reasonable? I am thinking this should prevent the NPE"

    You are likely to cause a race condition when opening and closing at a high frequency. Commenting out the line you suggested might seem to work, but you should check whether you start leaking memory or worse drain battery as you have somewhere an old native thread running in the background.

    Whenever you open a new game the SDLActivity will send a SDL Quit event, that gets relayed to LÖVE, which will then react to it, end its main() function, end its thread and then return to Java. After that a new thread will be started, which again is a cascade of events.

    A proper solution would be to add some kind of guard at GameActivity.onNewIntent().

  3. Karthik T

    now I see this if i start stop start reasonably fast.

    W/dalvikvm(12221): Invalid indirect reference 0x43137b68 in decodeIndirectRef
    I/dalvikvm(12221): "SDLThread" prio=5 tid=63 RUNNABLE
    I/dalvikvm(12221):   | group="main" sCount=0 dsCount=0 obj=0x43205080 self=0x7eb3c120
    I/dalvikvm(12221):   | sysTid=12536 nice=0 sched=0/0 cgrp=apps handle=2125710712
    I/dalvikvm(12221):   | state=R schedstat=( 38625467 24881618 132 ) utm=1 stm=2 core=2
    I/dalvikvm(12221):   at Method)
    I/dalvikvm(12221):   at
    I/dalvikvm(12221):   at


  4. Martin Felis reporter

    Hmm... I have no what idea what the error is supposed to mean. From a quick search and assuming you were spamming restarting of a game I would assume that the JVM and the native thread are somehow out of sync.

    What you could try is to only end the native thread when it is actually running. I would (for testing purposes) add a static variable bool native_initialized = false; to SDLActivity that is set to false in SDLActivity.initialize() and gets set to true in SDLActivity.flipBuffers(). Then in SDLActivity.resetNative() you only try to join the native Thread when native_initialized is true, or even better: in GameActivity.onNewIntent you only stop and start the native code when it is initialized.

    Makes sense?

  5. Martin Felis reporter

    Opening of a new .love file kills the old instance. There still might be issues when spamming the App by oppening .love files in a high frequency.

  6. Log in to comment