YouTube upload : callback on Mac OS10.4

1 view
Skip to first unread message

ichiro

unread,
Dec 20, 2009, 9:50:48 AM12/20/09
to Google Data APIs Objective-C Client Library Discussion
Hello
I am now working on the app which enable uploading videos to YouTube.
I am building the app on Mac OS10.5.8 (with Xcode3.1.3/GData objective-
c client library 1.9.1) but I also want the app working on Mac OS10.4.
One problem I have is I'm using modal dialog for displaying progress
(callbacks are deferred while a modal dialog is displayed). So I avoid
the problem by spawning the new thread for receiving callbacks from
GDataServiceGoogleYouTube using NSThread's
detachNewThreadSelector:toTarget:withObject: method. And in the thread
entry method, I set up the necessary information for uploading and
called the following method:

ticket = [service fetchEntryByInsertingEntry:entry forFeedURL:url
delegate:self didFinishSelector:@selector
(uploadTicket:finishedWithEntry:error:)];

Then, to prevent the thread to exit promptly, I added the code like
the following.

do
{
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:
[NSDate distantFuture]];
}
while (shouldWait);

On Mac OS10.5 it works just right -- Progress callbacks and didFinish
callback are called properly. On Mac OS10.4, progress callbacks are
repeatedly called as expected but at the time when didFinish callback
should be called, the app crashes with the report like the following:

Thread 8 Crashed:
0 com.apple.Foundation 0x9282ce13 _NSRaiseError + 227
1 com.apple.Foundation 0x92853c57 +[NSException
raise:format:] + 57
2 com.apple.Foundation 0x928dbfe2 -[NSObject
doesNotRecognizeSelector:] + 123
3 com.apple.Foundation 0x927ffd1b -[NSObject
(NSForwardInvocation) forward::] + 184
4 libobjc.A.dylib 0x90a5cba1 _objc_msgForward + 49
5 com.google.GDataFramework 0x0102427f
AssertSelectorNilOrImplementedWithArguments + 64031
6 com.google.GDataFramework 0x010154db
AssertSelectorNilOrImplementedWithArguments + 3195
7 com.apple.Foundation 0x92860794 -[NSURLConnection
(NSURLConnectionInternal) _sendDidFinishLoadingCallback] + 176
8 com.apple.Foundation 0x9285e839 -[NSURLConnection
(NSURLConnectionInternal) _sendCallbacks] + 748
9 com.apple.Foundation 0x9285e4d6 _sendCallbacks + 201
10 com.apple.CoreFoundation 0x9082cf06 CFRunLoopRunSpecific +
1213
11 com.apple.CoreFoundation 0x9082ca42 CFRunLoopRunInMode + 61
12 com.apple.Foundation 0x9282f6ca -[NSRunLoop
runMode:beforeDate:] + 182

Any ideas about the possible cause of the problem? Any comments or
advice would be a great help for me.
Thanks,
ichiro.

Greg Robbins

unread,
Dec 20, 2009, 4:12:32 PM12/20/09
to gdata-objec...@googlegroups.com
For Mac OS X 10.5 and later, you can use the service's setRunLoopModes: to allow the callbacks during modal dialogs. 

Generally, you should avoid creating new threads in Cocoa code; the operating system (and GData library) provide asynchronous APIs for any slow task. You cannot assume that most of Cocoa is safe to use from threads other than the main thread.

doesNotRecognizeSelector in the stack indicates that there is some attempt to send a message to an unavailable method. You could put a breakpoint at the library's objectFetcher:finishedWithData: methods in GDataServiceBase and GDataServiceGoogle, and hopefully catch the networking code callback before the exception.

Given the small number of users of new software on Mac OS X 10.4, you might want to substitute some simple alternative user interface rather than worry about callbacks during a modal dialog on that system.

ichiro

unread,
Dec 21, 2009, 6:49:27 AM12/21/09
to Google Data APIs Objective-C Client Library Discussion
Thank you, Greg.
I think when using GData library for Mac OS X 10.5 or later, the code
becomes amazingly simple.
I hope my future projects allow me to take more advantage from this
simplicity.
Reply all
Reply to author
Forward
0 new messages