Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS6: MFMailComposeViewController slow to load and flashes black screen; MailCompositionS begins hogging memory

On iOS 6, after sending a few email messages (by using MFMailComposeViewController), the email screens become very slow to open- at first opening with none of the fields populated (no Subject, no body, etc.) for a few seconds, and eventually (after sending about 8 messages), a black screen is displayed to the user for a few seconds before the email view controller is properly displayed.

The log spits out the following line before each black screen is displayed:

[MFMailComposeRemoteViewController: ....] timed out waiting for fence barrier from com.apple.MailCompositionService

Also, using MFMailComposeViewController on iOS6 causes the MailCompositionS process to start hogging memory (it's going all the way up to roughly 260MB on my iPhone). I'm assuming this is the reason for the MFMailComposeViewController display issues.

Everything runs fine on iOS 5. This issue only occurs on iOS 6.

Has anyone found a way to resolve this issue?

Thanks!

The code is standard, but I'll include it anyway:

-(IBAction)doEmailLog:(id)sender 
{    
    if( [self canSendMail] )
    {       
        // create the compose message view controller
        MFMailComposeViewController* mailComposer = [[MFMailComposeViewController alloc] init];

        // this class will handle the cancel / send results
        mailComposer.mailComposeDelegate = self;

        // fill in the header and body
        [mailComposer setSubject:@"My Subject"];
        [mailComposer setMessageBody:@"My message body" isHTML:NO];

        // attach log file
        if ([[NSFileManager defaultManager] fileExistsAtPath:filename])
        { 
            NSData *data = [NSData dataWithContentsOfFile:filename];
            [mailComposer addAttachmentData:data mimeType:@"text/plain" fileName:filename];
        }

        // show the view controller
        [self presentViewController:mailComposer animated:YES completion:^{LogTrace(@"Presented mail view controller");}];
    }
    else
    {
        ...
    }
}

-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
    ...

    // dismiss the compose message view controller
    [self dismissViewControllerAnimated:YES completion:^{LogTrace(@"Finished dismissing mail controller");}];
}
like image 692
Chrissy Harris Avatar asked Nov 08 '12 21:11

Chrissy Harris


1 Answers

on ios 6 the mail composer is its own app (inside yours) :: http://oleb.net/blog/2012/10/remote-view-controllers-in-ios-6/


the code looks good to me if you are using ARC else it leaks and on ios6 that might result in x XPC remotes

if all is good there, Id blame it on a bug in apple's new handling of XPC

like image 152
Daij-Djan Avatar answered Oct 22 '22 16:10

Daij-Djan