composer scene:show "did" triggers too soon.

Hello,

I am loading a sprite in the scene:create part and starting the animation in the scene:show did phase.

But the audio for the sprite and the sprite animation start while the screen is still black. 

How can I fix this?

I don’t want to create a delay timer to delay it even longer. The load times differ per device.

[lua]

function scene:create( event )

    

    local sceneGroup = self.view

    local background=newImage(sceneGroup,“plaatjes/splashScreen.png”,1024,768)

    PlaceImageCenter(background)

    monster1HoofdSprite = display.newSprite( sceneGroup,monster1HoofdSheet,monster1SequenceData )

    monster1HoofdSprite.x=myWidth*0.3

    monster1HoofdSprite.y=myHeight*0.6

    

    – Initialize the scene here.

    – Example: add display objects to “sceneGroup”, add touch listeners, etc.

end

– “scene:show()”

function scene:show( event )

    

    local sceneGroup = self.view

    local phase = event.phase

    

    if ( phase == “will” ) then

        – Called when the scene is still off screen (but is about to come on screen).

    elseif ( phase == “did” ) then

        – Called when the scene is now on screen.

        – Insert code here to make the scene come alive.

        – Example: start timers, begin animation, play audio, etc.

        

        local function NextScreen()

             composer.gotoScene( “hoofdmenu-iPad”,{effect = “crossFade”,time=500} )

        end

        monster1HoofdSprite:setSequence(“dance”)

        monster1HoofdSprite:play()

        audio.play(monsterBrul)

        timer.performWithDelay(2600,NextScreen)

    end

end

[/lua]

There is a filed bug report for this: #31898 and engineering is looking into it.

Rob

Ok, thanks. 

That actually saves me a lot of time trying to figure out a way to fix this. 

We have the exact same problem. Audio and animation from scene:show “did” begin while the previous scene is still on the screen.

Has this been resolved yet?

Using public release 2014.2189

There is a similar bug 31898 that has not been solved yet. It’s about the did phase of the hide event firing too soon.  Your bug sounds different but related.  I would suggest if you have a sample app that shows the bug in action, an additional bug report focused on showing happening too early could be useful.  Your bug report must be a .zip file with all required assets for it to run including a build.settings and config.lua.  Then use the “Report a bug” link at the top of the page.

Rob

suggestion:  have engineering look at the flow of events for those effects where concurrent=true

(and also expect that previous scene’s did-hide also triggers too soon, same cause)

same bug has been present in storyboard “forever” (i’ve since fixed it for myself in the legacy source) and I’d put money that it’s still the same in composer.

hth

Hi, I’m having the same problem here in two different situations. 

1 - I’m having a huge delay between scenes with composer, so I tried to show a “loading” message between them. The funny part is the “did show” of the next scene is called very fast and the “loading” of my previous screen doesn’t have enough time to appear. However, all of these events occur while the next screen is still out of the screen. If I print a os.time in my previous screen tap event and a os.time in the “did show” of the next screen, the time difference is basically zero, which is not true. Also I can see the print output of the “did show” before I can see the next scene, which is very weird. The result is that I have no “loading” on the screen, and the transition still have a huge delay.

2 - When my game starts I need to run a function who loads a huge module on memory (it’s a word list with about 30MB, it’s a dictionary game). Of course, this take a while. So I tried to show a “loading” screen during this task. I’ve created a scene to solve this. This scene creates a “loading” message on “create”, and runs this slow function on “did show”, after that I call the next scene. However, apparently this slow function has been called before the loading message is on the screen, every time a call this scene I get a black screen during a few seconds (the execution of the slow function).

These are two different situations, but I think both have the same source problem, which is the “did show” running before the scene is really on the screen. 

Do you think this bug that you are working on can solve this?

Thanks

Just to confirm, our bug is the same as Juf Jannie has reported. Show:did for the next scene is starting while the previous scene is still on screen.

Printing to the console in XCode shows that audio and animations start in scene:create while the previous scene is still on screen. Then a second later the next screen suddenly displays after a second of the animation and sounds have already passed and then the console prints out the rest of the composer steps from scene1:hide did through to scene1: destroy.

 ---- scene:create scene2

–  assets are loaded in

– This is where the animations and sound begin while scene 1 is still on screen.

------Scene 1:Hide DID
-------- Scene 2: Show:WILL
-------- Scene 2: Show: DID

– Audio and animations should be starting here where they have been called.

-----Scene1: Destroy

Hi davebollinger. If you have found a fix for this do you think it is worth pointing it out to the engineers? It’s disheartening to know the same problem exists in storyboard and has gone unfixed. We were considering ditching composer if it is so buggy for storyboard but perhaps not.

as a test, and with a nice long time that you can notice:

  1. use the “fade” effect (which is not concurrent), does problem go away?

  2. now try “crossFade” (which is concurrent), does problem return?

if so, then same problem as storyboard.  in storyboard, a function named “nextTransition” is called when the previous scene finishes its transition and starts the transition on the current scene, issuing didExit (aka hide-did) and willEnter (aka show-will) events in between.

that works fine for sequential effects.

but its also reused for concurrent effects to fire both transitions simultaneously at start.  the result is those events (specifically didExitScene aka hide-did) are issued too soon.

if not, then there’s perhaps some other problem w composer’s event flow.

Hi davebollinger, I did some tests with your suggestions:

1 - Indeed “fade” solves the problem, the show:did was invoked only with the second scene on the screen, but curiously “crossFade” does too. I’ve tested even with time = 1.

2 - I’ve tested in two situations, from scene to scene and from main to the first scene. From scene to scene with “fade” or “crossFade”, even with time = 1, works fine, however from the main to the first scene, the problem continues.

Hope it helps to solve the problem…

davebollinger - thank you very much! Your suggestion works perfectly!

The work around is to use “crossFade” with a time of only 1 (“fade” results in a quick blip of black).

Crisis averted… for now. We were depressed, now we’re back from the brink.

Thanks again.

well, cool if you found something that works for you, though i wasn’t really suggesting it as a workaround.

rather i was suggesting it as a way to test if the bug rob mentioned in composer was same/similar as storyboard’s.  that bug was for the did-hide event, and i know where the equivalent didExitScene bug occurs in storyboard.

what i don’t know, from having access to storyboard source only, is how did-show (aka willEnterScene) might also fire early (the topic of THIS thread).  they *might* be related in composer, given that portions may have been rewritten, but i don’t see any likely mechanism to get THAT specific bug with storyboard.  thus that test was to see if composer’s did-show bug might ALSO be related to the concurrent effects event flow (since it’s already suspect due to the did-hide problem)

There is a filed bug report for this: #31898 and engineering is looking into it.

Rob

Ok, thanks. 

That actually saves me a lot of time trying to figure out a way to fix this. 

We have the exact same problem. Audio and animation from scene:show “did” begin while the previous scene is still on the screen.

Has this been resolved yet?

Using public release 2014.2189

There is a similar bug 31898 that has not been solved yet. It’s about the did phase of the hide event firing too soon.  Your bug sounds different but related.  I would suggest if you have a sample app that shows the bug in action, an additional bug report focused on showing happening too early could be useful.  Your bug report must be a .zip file with all required assets for it to run including a build.settings and config.lua.  Then use the “Report a bug” link at the top of the page.

Rob

suggestion:  have engineering look at the flow of events for those effects where concurrent=true

(and also expect that previous scene’s did-hide also triggers too soon, same cause)

same bug has been present in storyboard “forever” (i’ve since fixed it for myself in the legacy source) and I’d put money that it’s still the same in composer.

hth

Hi, I’m having the same problem here in two different situations. 

1 - I’m having a huge delay between scenes with composer, so I tried to show a “loading” message between them. The funny part is the “did show” of the next scene is called very fast and the “loading” of my previous screen doesn’t have enough time to appear. However, all of these events occur while the next screen is still out of the screen. If I print a os.time in my previous screen tap event and a os.time in the “did show” of the next screen, the time difference is basically zero, which is not true. Also I can see the print output of the “did show” before I can see the next scene, which is very weird. The result is that I have no “loading” on the screen, and the transition still have a huge delay.

2 - When my game starts I need to run a function who loads a huge module on memory (it’s a word list with about 30MB, it’s a dictionary game). Of course, this take a while. So I tried to show a “loading” screen during this task. I’ve created a scene to solve this. This scene creates a “loading” message on “create”, and runs this slow function on “did show”, after that I call the next scene. However, apparently this slow function has been called before the loading message is on the screen, every time a call this scene I get a black screen during a few seconds (the execution of the slow function).

These are two different situations, but I think both have the same source problem, which is the “did show” running before the scene is really on the screen. 

Do you think this bug that you are working on can solve this?

Thanks

Just to confirm, our bug is the same as Juf Jannie has reported. Show:did for the next scene is starting while the previous scene is still on screen.

Printing to the console in XCode shows that audio and animations start in scene:create while the previous scene is still on screen. Then a second later the next screen suddenly displays after a second of the animation and sounds have already passed and then the console prints out the rest of the composer steps from scene1:hide did through to scene1: destroy.

 ---- scene:create scene2

–  assets are loaded in

– This is where the animations and sound begin while scene 1 is still on screen.

------Scene 1:Hide DID
-------- Scene 2: Show:WILL
-------- Scene 2: Show: DID

– Audio and animations should be starting here where they have been called.

-----Scene1: Destroy