App stops working

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
nextyoyoma
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 37
Joined: Sat Oct 06, 2012 6:29 am

App stops working

Post by nextyoyoma » Fri Oct 26, 2012 9:32 pm

We have an iPad running as a window sign. I wrote an app that runs on it all the time. It displays an image on the bottom with our helpdesk hours and a video on the top. The image and video change based on the time of day. That information is pulled from a mysql database. Basic workflow of the app is this:

1) Check the database for settings
2) Create player with "mobileControlCreate" and start video playing
3) wait for playerFinished message, then start over.

For some reason, the app completely stops working after about 4 hours. I set up some logging to the app's document folder, and I found that at some point, there is no "playerFinished" message getting received, and at that point, everything just stops. Usually when it starts playing, the "playerProgressChanged" message is sent twice; once as soon as it is loaded, and once again a few seconds later when it has fully buffered the (locally stored) video.

I have attached the complete stack for reference (sanitized). Between that and the log excerpt, perhaps someone can shed some light on this?
10/26/12 13:48:08 - Player Finished.
10/26/12 13:48:08 - Starting setSource
10/26/12 13:48:08 - preSearchSuccess is"yes".
10/26/12 13:48:08 - About to set up the player. The variables are:
currentPeriod = 6 | currentMovie = topmovie.mov | currentPicture = opensign.png
10/26/12 13:48:08 - Player set up successfully. Movie now playing
10/26/12 13:48:08 - Image set successfully.
10/26/12 13:48:08 - Starting preSearch
10/26/12 13:48:08 - Connecting to database
10/26/12 13:48:08 - Database connection 2035 closed.
10/26/12 13:48:08 - Database connected with connection ID 2043
10/26/12 13:48:09 - PreSearch complete
10/26/12 13:48:09 - Player Progress changed; loadState is and playback state is playing
10/26/12 13:48:09 - Player Progress changed; loadState is playable,playthrough and playback state is playing
10/26/12 13:49:03 - Player Finished.
10/26/12 13:49:03 - Starting setSource
10/26/12 13:49:03 - preSearchSuccess is"yes".
10/26/12 13:49:03 - About to set up the player. The variables are:
currentPeriod = 6 | currentMovie = topmovie.mov | currentPicture = opensign.png
10/26/12 13:49:03 - Player set up successfully. Movie now playing
10/26/12 13:49:03 - Image set successfully.
10/26/12 13:49:03 - Starting preSearch
10/26/12 13:49:03 - Connecting to database
10/26/12 13:49:03 - Database connection 2043 closed.
10/26/12 13:49:04 - Database connected with connection ID 2051
10/26/12 13:49:04 - PreSearch complete
10/26/12 13:49:04 - Player Progress changed; loadState is and playback state is playing ##This is where the app stops working
As you can see, there are usually two playerProgressChanged messages sent after the movie starts playing, but when it stops, only one message is sent. Hopefully someone will be kind enough to help me figure this out. Thanks!
Attachments
ipadwindowDEBUG.livecode.zip
(4.35 KiB) Downloaded 259 times

nextyoyoma
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 37
Joined: Sat Oct 06, 2012 6:29 am

Re: App stops working

Post by nextyoyoma » Mon Oct 29, 2012 8:18 pm

Just a quick update. I thought maybe the video was just getting stalled, but after testing it looks like the app is totally locking up. I set the player controls to visible, but when the issue happens they don't appear when tapping the screen.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: App stops working

Post by jacque » Tue Oct 30, 2012 5:47 am

Can you isolate the functional part of your script and post it here? You'll often get more replies that way, since people don't always have time to download and go through a whole stack. But if they can just read a bit of the script, sometimes they'll notice something.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

nextyoyoma
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 37
Joined: Sat Oct 06, 2012 6:29 am

Re: App stops working

Post by nextyoyoma » Tue Oct 30, 2012 2:48 pm

I was about to post more of my stack, but I I think I found the problem (but not the solution).

Whenever my app locks up and I restart it, it fails to resume and crashes. After that it works fine. Looking at the system-generated crash report, I see that it is trying to resume over 500 threads, most of which are "com.apple.storeservices.SSDownloadManager.background." Based on the timing of other log entries, I'm pretty sure that thread is spawned whenever I call revopendatabase (or possible revdatafromquery), and that thread is never terminated, even though I always disconnect with revCloseDatabase. Obviously the app eventually locks up once so many threads are running. Is there some way to ensure that this thread gets closed?

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: App stops working

Post by jacque » Tue Oct 30, 2012 4:55 pm

It may not be the database. Where are your videos coming from? Are they streaming or on disk? How are you managing the player object? Deleting and recreating it, or reassigning a url to an existing one?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

nextyoyoma
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 37
Joined: Sat Oct 06, 2012 6:29 am

Re: App stops working

Post by nextyoyoma » Tue Oct 30, 2012 6:26 pm

jacque wrote:It may not be the database. Where are your videos coming from? Are they streaming or on disk? How are you managing the player object? Deleting and recreating it, or reassigning a url to an existing one?
They are on disk (documents folder). Player object is being deleted and recreated each time. I know that the player is created successfully, and that the playbackState does get to "playing" before everything freezes. See my first post for a log excerpt. The relevant portion of code is below:

Code: Select all

  
command setSource
 //Before this, the handler contains commands to connect to the database to see what the filename of the movie we should be playing is.
   // After that, we delete the player so we can replace it with a new one
   
   logEntry "About to set up the player.  The variables are:" & return & tab & "currentPeriod =" && currentPeriod && "|" && "currentMovie =" && currentMovie && "|" && "currentPicture =" && currentPicture
   
   if "ioscontrol" is among the lines of mobileControls() then
      mobileControlDelete "ioscontrol"
   end if 
   
   // Create the video player and set the source file, then start the video
   
   mobileControlCreate "player", "ioscontrol"
   put the result into playerID
   
   mobileControlSet "ioscontrol", "filename", currentMovie
   mobileControlSet "ioscontrol", "preserveAspect", true
   mobileControlSet "ioscontrol", "showController", false
   mobileControlSet "ioscontrol", "visible", true
   mobileControlSet "ioscontrol", "looping", false
   mobileControlSet "ioscontrol", "rect", "0,0,768,576"
   mobileControlSet "ioscontrol", "file", currentMovie
   
   mobileControlDo "ioscontrol", "play"
   
   logEntry "Player set up successfully.  Movie now playing"
   
   //Set the bottom image that will play
   
   set the fileName of image "imgarea" to currentPicture
   
   logEntry "Image set successfully."
   
   preSearch
catch errVar
   answer "The problem is in set source:" && errVar
end try

end setsource

on playerFinished
setsource
end playerFinished
So it could be the player stalling, but I also have a handler for playerError and it never gets called.

Does it sound normal to have over 500 of the same thread try to resume when launching the app?

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: App stops working

Post by jacque » Wed Oct 31, 2012 5:56 pm

No, it shouldn't do that. You're doing all the right things so it sounds like the engine isn't cleaning up correctly. I vaguely recall a problem with mobileControlDelete where the control was not correctly removed under specific circumstances. Your situation sounds similar. I think you should bug report it.

A workaround might be to use only a single control and just reset the file content.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

nextyoyoma
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 37
Joined: Sat Oct 06, 2012 6:29 am

Re: App stops working

Post by nextyoyoma » Fri Nov 02, 2012 6:28 pm

Glad to know I'm not going crazy! Thanks.

I'm probably missing something obvious, but when I go to http://quality.runrev.com/, I don't see anywhere I can register. My credentials for the forums don't work, and I don't get a register prompt after submitting incorrect credentials.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: App stops working

Post by jacque » Fri Nov 02, 2012 7:54 pm

If you aren't in the developer program then you won't have direct access to the bug database. But you can send a report to support and they will take care of it for you. They will want a clear recipe, and a simple sample stack that demonstrates the problem without any extra stuff; i.e., they dont want your whole project, just a representative segment.

If you are in fact in the developer program and you missed the email, write to support and ask what your access credentials are.

I'd still try the single-player solution though. I think that will work since you don't have to create and destroy native controls that way.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply