arachide
arachide

Reputation: 8076

MFMailComposeViewController hangs app on iOS 4.3

I used the code below to send mail:

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"my title"];
NSMutableString *emailBody = [[NSMutableString alloc] initWithString:  @"Hi\n\n"];
[emailBody appendString: @"test"];  
[picker setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:picker animated:YES];
[picker release];
[emailBody release];

The code works well on old OS version (Base SDK 5.0, Deployment Target 4.0). I just upgraded to Xcode 4.5 with iOS 6.0 as the Base SDK, Deployment Target still 4.3, and the code still works well on Simulator with 5.0, 5.1, and 6.0.

Now I installed the app to iPad with iOS 4.3.3. The MFMailComposeViewController does not appear, it hogs and the app stops working. I checked the device log, it displays:

Incident Identifier: 53CF815B-36FB-4523-8E58-03D80E6BD2D6
CrashReporter Key:   e1ce74069fc4d91cdf244ef60282649f2ea4716e
Hardware Model:      iPad1,1
Process:         MyApp [1018]
Path:            /var/mobile/Applications/75088803-4768-4CD6-A561-553F4A182229/MyApp.app/MyApp
Identifier:      MyApp
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Date/Time:       2012-11-16 14:29:59.959 +0800
OS Version:      iPhone OS 4.3.3 (8J3)
Report Version:  104

Exception Type:  00000020
Exception Codes: 0x8badf00d
Highlighted Thread:  0

Application Specific Information:
MyApp[1018] has active assertions beyond permitted time: 
{(
    <SBProcessAssertion: 0x1fa0dd00> identifier: Suspending process: MyApp[1018] permittedBackgroundDuration: 10.000000 reason: suspend owner pid:30 preventSuspend  preventThrottleDownCPU  preventThrottleDownUI 
)}

Elapsed total CPU time (seconds): 0.770 (user 0.460, system 0.310), 8% CPU 
Elapsed application CPU time (seconds): 0.000, 0% CPU

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0:
0   libsystem_kernel.dylib          0x332e5c00 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x332e5758 mach_msg + 44
2   AppSupport                      0x33bbb7b8 CPDMTwoWayMessage + 164
3   AppSupport                      0x33bba530 -[CPDistributedMessagingCenter _sendMessage:userInfoData:oolKey:oolData:makeServer:receiveReply:nonBlocking:error:] + 352
4   AppSupport                      0x33bba0b2 -[CPDistributedMessagingCenter _sendMessage:userInfo:receiveReply:error:toTarget:selector:context:nonBlocking:] + 618
5   AppSupport                      0x33bb91ae -[CPDistributedMessagingCenter _sendMessage:userInfo:receiveReply:error:toTarget:selector:context:] + 58
6   AppSupport                      0x33bb9312 -[CPDistributedMessagingCenter sendMessageAndReceiveReplyName:userInfo:] + 42
7   MessageUI                       0x3693c1fa _CallMessageUIServiceMethod + 182
8   MessageUI                       0x3693c01e +[MFMailAccountProxy reloadAccounts] + 22
9   MessageUI                       0x3693bf6c +[MFMailComposeController _refreshMailAccountsIfNecessary] + 32
10  MessageUI                       0x3693bf2a +[MFMailComposeController isSetupForDelivery] + 10
11  MessageUI                       0x3693be80 +[MFMailComposeViewController canSendMail] + 24
12  MessageUI                       0x3693bc36 -[MFMailComposeViewController initWithComposition:contentSize:mailComposeControllerOptions:] + 42
13  MessageUI                       0x3693bbf8 -[MFMailComposeViewController initWithComposition:] + 28
14  MessageUI                       0x36963fac -[MFMailComposeViewController initWithNibName:bundle:] + 44
15  UIKit                           0x329e8a0c -[UIViewController init] + 12
16  MyApp                       0x000d09ee 0xb5000 + 113134
17  MyApp                       0x000e3820 0xb5000 + 190496
18  UIKit                           0x32ad1036 -[UIActionSheet(Private) _buttonClicked:] + 186
19  CoreFoundation                  0x32dc956a -[NSObject(NSObject) performSelector:withObject:withObject:] + 18
20  UIKit                           0x329ceec2 -[UIApplication sendAction:to:from:forEvent:] + 78
21  UIKit                           0x329cee62 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 26
22  UIKit                           0x329cee34 -[UIControl sendAction:to:forEvent:] + 32
23  UIKit                           0x329ceb86 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 350
24  UIKit                           0x329cf41c -[UIControl touchesEnded:withEvent:] + 336
25  UIKit                           0x329cdbee -[UIWindow _sendTouchesForEvent:] + 362
26  UIKit                           0x329cd568 -[UIWindow sendEvent:] + 256
27  UIKit                           0x329b630c -[UIApplication sendEvent:] + 292
28  UIKit                           0x329b5c4c _UIApplicationHandleEvent + 5084
29  GraphicsServices                0x35c8ee70 PurpleEventCallback + 660
30  CoreFoundation                  0x32e30a90 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 20
31  CoreFoundation                  0x32e32838 __CFRunLoopDoSource1 + 160
32  CoreFoundation                  0x32e33606 __CFRunLoopRun + 514
33  CoreFoundation                  0x32dc3ebc CFRunLoopRunSpecific + 224
34  CoreFoundation                  0x32dc3dc4 CFRunLoopRunInMode + 52
35  GraphicsServices                0x35c8e418 GSEventRunModal + 108
36  GraphicsServices                0x35c8e4c4 GSEventRun + 56
37  UIKit                           0x329e0d62 -[UIApplication _run] + 398
38  UIKit                           0x329de800 UIApplicationMain + 664
39  MyApp                       0x000c95a4 0xb5000 + 83364
40  MyApp                       0x000b73b8 0xb5000 + 9144

Thread 1 name:  Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0   libsystem_kernel.dylib          0x332e8fbc kevent + 24
1   libdispatch.dylib               0x33abc032 _dispatch_mgr_invoke + 706
2   libdispatch.dylib               0x33abd03a _dispatch_queue_invoke + 86
3   libdispatch.dylib               0x33abc5ea _dispatch_worker_thread2 + 186
4   libsystem_c.dylib               0x363d958a _pthread_wqthread + 258
5   libsystem_c.dylib               0x363d9bbc start_wqthread + 0

Thread 2 name:  WebThread
Thread 2:
0   libsystem_kernel.dylib          0x332e5c00 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x332e5758 mach_msg + 44
2   CoreFoundation                  0x32e312b8 __CFRunLoopServiceMachPort + 88
3   CoreFoundation                  0x32e33562 __CFRunLoopRun + 350
4   CoreFoundation                  0x32dc3ebc CFRunLoopRunSpecific + 224
5   CoreFoundation                  0x32dc3dc4 CFRunLoopRunInMode + 52
6   WebCore                         0x31e5c27e RunWebThread(void*) + 382
7   libsystem_c.dylib               0x363d830a _pthread_start + 242
8   libsystem_c.dylib               0x363d9bb4 thread_start + 0

Any comment welcome.

Upvotes: 1

Views: 268

Answers (1)

zoul
zoul

Reputation: 104115

The stack trace looks like this is not your fault, it’s system code that hangs and leads to your app being killed. There’s a post in the Developer Forums (non-public link, sorry) that suggest that this might be connected to the system Mail.app.

I’d try rebooting the device and similar tricks, but in the end your app might still be unstable on 4.3 in general. Do you really need to support 4.3?

Upvotes: 1

Related Questions