Malloc_error when changing views in UINavigationController

Home Forums OpenEars plugins Malloc_error when changing views in UINavigationController

Viewing 19 posts - 1 through 19 (of 19 total)

  • Author
    Posts
  • #1018389
    tbeagley
    Participant

    After speech has been instantiated if I attempt to change view controllers the app crashes. If speech is not instantiated I am able to freely move between view controllers.

    Only one of the view controllers uses flite/neatspeech. I am able to start and stop speech using the code contained in the guide that came along with my order. There are no current issues if I remain in the view controller that contains the speech code.

    Is there something I need to do in order to deallocate or free flite/neatspeech when switching between view controllers?

    error is:
    malloc: *** error for object 0x210535c0: pointer being freed was not allocated

    This is in Xcode 5 using ARC.

    #1018393
    Halle Winkler
    Politepix

    Welcome,

    This could be a bug in 1.5, but first I wanted to ask whether you are sending a [self.fliteController stopSpeaking]; message before exiting the view controller.

    #1018396
    tbeagley
    Participant

    Yes, every button that takes the user away from the page of spoken contents sends that message, including when the view is changed.

    I see that the command is obeyed (the speech stops) but as soon as the view controller unloads I get the error. Setting the break point in malloc_error_break doesn’t tell me much (I’m a bit new to Xcode and ObjC)

    How do you typically handle having flite/openears in a navigation project with multiple views? Would you import everything into the AppDelegate files (or some other files) and reference from there? Or should it “just work” when resources are de or reallocated from one view to another view?

    #1018397
    Halle Winkler
    Politepix

    In the case of PocketsphinxController it has to be a single instantiation and is designed to be able to deliver info to any part of the app using OpenEarsEventsObserver so it should go in the root view controller and stay there IMO (very little should go in your AppDelegate).

    In the case of FliteController it isn’t intended to be restricted to a single root view controller so I consider this buggy behavior. I think you can work around it for now by treating it in the same way as PocketsphinxController but I am going to look into what is going on with that tomorrow and get back to you because it ought to be able to deallocate if it is stopped properly. Can you share with me the device and OS version for testing?

    Yes, every button that takes the user away from the page of spoken contents sends that message, including when the view is changed.

    Can I see a snippet of the button-activated code?

    #1018398
    tbeagley
    Participant

    I was really hoping to push this out today. I didn’t realize you were in Germany.

    Here’s one of the buttons that would stop speech:

    - (IBAction)btnBrowse:(id)sender {
        
        [self.fliteController stopSpeaking];
        
        //go back to a url where we get some data from JSON
        NSString *website = [NSString stringWithFormat:@"...some URL"];
        NSURL *url = [NSURL URLWithString:website];
        NSURLRequest *requestURL = [NSURLRequest requestWithURL:url];
        [webBoxPDF01 loadRequest:requestURL];
        
    }

    that stops the speech, but when I exit that view using the navigation controller’s back button it crashes.

    And I’ve even taken to adding this to my .mm file for the view that uses fliteController:

    - (void)dealloc {
        [self.fliteController stopSpeaking];
    }

    The voice stops speaking, but again, the app crashes.

    #1018401
    tbeagley
    Participant

    Device is an iPhone 4s and OS is 6.1.3 (most of the users in my company disregard os upgrades, so I’ll need to support 6.x for a while)

    The issue also occurs on a 4s running iOS 7 and in the emulators running both versions.

    #1018402
    tbeagley
    Participant

    Not sure if it helps, but here’s the code where the speech is triggered:

    //labels from JSON data for visual and audio
    NSString *readLabels = [NSString stringWithFormat:@"%@%@%@",self.lblRead1.text,self.lblRead2.text,self.lblRead3.text];
        
    //some lazy code based on the user's voice prefs (male or female)
        if ([voiceIsSet isEqualToString:voiceIsEmma]) {
            [self.fliteController sayWithNeatSpeech:readLabels withVoice:self.ealt];
        } else {
            [self.fliteController sayWithNeatSpeech:readLabels withVoice:self.william];
        }
    #1018403
    Halle Winkler
    Politepix

    Hi tbeagley,

    I’m sorry for the issue. Since this is a bug it will require a plugin update to fix, so even if I were in the same timezone as you I wouldn’t be able to find the issue, fix it, test the fix and push the update quickly enough for you to publish today, but I understand that you have time pressure and that this is a blocker. It is now the top priority and I’ll have more info for you tomorrow.

    I expect that a workaround that will work right now would be to keep it in a root level view controller and message it from child view controllers with delegate methods or notifications to control the speech.

    #1018404
    Halle Winkler
    Politepix

    Thanks for following up with more code. When you get the crash, what happens if you type “bt” into the blue llvm prompt in the debug console?

    #1018405
    tbeagley
    Participant

    Thanks for the quick replies, Halle. I appreciate the time you’ve given me.

    I’ll attempt the workaround for now and I look forward to your updates.

    #1018407
    Halle Winkler
    Politepix

    No problem at all, definitely don’t want any crashes so I’m glad to be alerted. I’ll follow up soon.

    #1018409
    Halle Winkler
    Politepix

    That’s a helpful backtrace, thanks. I’ve saved it and removed it from the post.

    #1018416
    tbeagley
    Participant

    Just checking in, any new info?

    #1018417
    Halle Winkler
    Politepix

    I’ve removed the source of the crash but there is now a leak, so I’m investigating the leak. No worries, I’m not going to forget to follow up with you.

    #1018418
    tbeagley
    Participant

    Great to hear, thanks a ton.

    #1018419
    Halle Winkler
    Politepix

    OK, I just sent you an email with a link to a version to check out — let me know how it’s working for you.

    #1018420
    tbeagley
    Participant

    I’ll let you know right away.

    #1018421
    tbeagley
    Participant

    Works like a charm, Halle.

    Thanks for the amazing response!

    I have another unrelated question, is it better to just start a new thread? (regarding word pronunciation and dictionaries)

    #1018422
    Halle Winkler
    Politepix

    Great to hear it — you’re welcome, and thanks for helpful info about the issue. Yes, it’s probably better to start a new thread because then I can point other forum users to it if it comes up again.

Viewing 19 posts - 1 through 19 (of 19 total)
  • You must be logged in to reply to this topic.