Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Random App Freezing

When I click "Launch" in Titanium, my app yields no errors. It loads the Default image, then as soon as it removes it and shows my app, my app will freeze at various stages.

  • Sometimes this is after it has loaded a few labels and a button.
  • Sometimes it freezes before it loads anything.
  • Sometimes it works perfectly.

How in the world can I figure out what could be causing this?

Thanks!

(Using 1.2.1 with Mobile SDK 1.4 on an iPhone (latest SDK))

— asked August 12th 2010 by Clifton Labrum
  • app
  • freeze
  • hang
3 Comments
  • I noticed this is one of my log files:

    Terminating in response to SpringBoard's termination.

    — commented August 12th 2010 by Clifton Labrum
  • I have about 26 images (including @2x duplicates for iPhone 4) totally just over 700kB). Could that be a problem? Doesn't seem like much for the app to handle.

    — commented August 13th 2010 by Clifton Labrum
  • I have conclusively determined that the freezing is random. I've set various break points, and I can't get consistently get to them. It just depends on the build.

    — commented August 13th 2010 by Clifton Labrum

6 Answers

  • Clifton, just a test,
    disable the analytics setting it to false in tiapp.xml

    I had similar problem sometimes ago.
    let me know.

    — answered September 8th 2010 by Andrea S
    permalink
    0 Comments
  • As far as I can tell, the app is choking on something in here.

    Either that or the include function I'm using to reference it:

    Ti.include('includes/left.js');
    

    I'm up to like 20 hours debugging this.

    Can I get some help? Anyone? :)

    — answered August 13th 2010 by Clifton Labrum
    permalink
    0 Comments
  • I donno,
    Try to use hide() and show() instead of visible, and do this after you add the elements to the window. Should be fast enough for the user not to see it.

    You can compile the project using xcode and look at the gdb console. Usually it helps me a lot.

    — answered August 13th 2010 by Dan Tamas
    permalink
    0 Comments
  • Isn't the Xcode console the same as the Titanium one? I'm looking at the DEBUG stuff in Ti, and it doesn't give me any hints.

    — answered August 13th 2010 by Clifton Labrum
    permalink
    0 Comments
  • Sometimes no :)

    — answered August 13th 2010 by Dan Tamas
    permalink
    0 Comments
  • I'm seeing the same behaviour in my app in the simulator and on my iPhone. Using Titanium 1.2.1 with SDK 1.4.0 on Snow Leopard. Usually it happens on clicking a button, where the button will remain highlighted and the entire app will be non-responsive.

    My app is, at this point, very vanilla: nothing but windows with labels and buttons that map out the user interaction. No loading of resources, no saving to files or SQLite databases.

    — answered September 8th 2010 by Justin Johnson
    permalink
    5 Comments
    • Justin, I eventually got this figured out but the solution wasn't simple. If you put your code on Pastie and give me the link, I might be able to help you.

      — commented September 8th 2010 by Clifton Labrum
    • Unfortunately, it's not even consistent to a particular file (of which there are now 17). What is consistent is that, when it happens, it's 1) always in click event listeners that 2) close the current window and open the next. This is the one where it happens most often:

      gameSpeedButton.addEventListener('click', function()
      {
          gameSpeedWindow.close();
          playersWindow.open();
      });
      

      Nothing special there at all, and so far all the windows do is add buttons and labels; no graphics or sound at all. This started happening after upgrading to the 1.4.0 SDK with iOS 4.0.2 SDK.

      Any help is appreciated. Can you describe generally what the problem was?

      — commented September 8th 2010 by Justin Johnson
    • The timing of opening and closing windows is pretty touchy. A couple pointers:

      1. Ensure that you're always opening a window after everything has been added to it. This usually means putting and window.open() code at the bottom of your JS file.
      2. Try opening the playersWindow in a 'close' callback for the gameSpeedWindow like this:
        gameSpeedWindow.addEventListener('close',function(){
        playersWindow.open();
        });
        

      — commented September 8th 2010 by Clifton Labrum
    • That appears to work–I was before able to reproduce it about 1 in 2 times. However, now the subsequent window is always freezing before fully displaying all the items.

      Generally, my code is structured as one file per window, with each file creating the window, creating the controls, adding them to the window, and then not opening the window, which only happens when the click event for the prior window fires (or now the close event). No windows are opened until all the files are included, so in theory they should all be created and populated with controls (there are no shared controls between them). The files are included in app.js with Ti.include(). Should I be opening the windows and swapping them around with hide() and show() instead? More generally, am I structuring this badly?

      — commented September 8th 2010 by Justin Johnson
    • Update: switching most of my windows to hide/show rather than open/close has resolved this issue for me.

      — commented September 10th 2010 by Justin Johnson
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.