WCErrorDomain Code=7009

I get this error when I try to transfer a .mov file recorded by UIImagePickerController on iPhone to the Watch:


Error Domain=WCErrorDomain Code=7009 "Payload is too large." UserInfo={NSLocalizedDescription=Payload is too large., NSLocalizedRecoverySuggestion=Send smaller payloads.}


But the file is not too large. In fact it's only about 208KB. In the same project I transfered an audio file that was 346KB large and it was successful.

I also tried AVAssetExportSession to reduce the size and dimension of the video and exported it with AVAssetExportPreset640x480 preset. The file size reduced from 208KB to 206KB. It failed again with the same error. To transfer it I used session.transferFile(_, metadata:). Has anyone else seen this? Any idea?


Thanks.

Replies

I am not sure if this is a bug, however, I filed a bug report for it in case it's a bug: 22838037.

thanks for the bug report. I'll make sure this gets routed to the right engineers promptly!

I'm also getting this when I try to send an NSDictionary via sendMessage, as follows:


eventName is an NSString, and eventImageData is a 312x555 image converted into NSData.


NSDictionary *userInfo = @{@"eventName" : eventName, @"eventImageData" : eventImageData};
[[WCSession defaultSession] sendMessage:userInfo replyHandler:^(NSDictionary<NSString *,id> * __nonnull replyMessage) {
     // Handle reply
} errorHandler:^(NSError * __nonnull error) {
     // Handle error
}];


Log:

image: height = 555.000000, width = 312.000000
error = Error Domain=WCErrorDomain Code=7009 "Payload is too large." UserInfo={NSLocalizedDescription=Payload is too large., NSLocalizedRecoverySuggestion=Send smaller payloads.}


The NSData size is 191524 in this instance, which is about 188kb. Why can't I send 188kb to the Watch via sendMessage?

sendMessage is intended for small, "realtime" messaging. For sending an image you should really be using transferFile as you are likely going to want it persisted to disk anyway.

transferFile never worked for me, which is why I switched to sendMessage. I cannot find a single example of transferFile on the net where it actually works.


Also, by making us use transferFile, you're making us write so much extra code to handle deleting unused images when they're no longer needed, and there's no information on how to move (or where to move) a file to once it's transferred. You just say to move it out of ~Documents/Inbox/. To where?! The documentation provides a link to a generic topic on file management on OS X, which is less than helpful.


If you can provide a working example of code that shows me how to move a file I've just received, then that might help. Bear in mind, though, that I cannot get didReceiveFile: to actually trigger in the Watch app.


My app (When's That) allows you to choose a picture for your background, and that's the image I want to send to the Watch app, but obviously I don't need to send the full-size image, so I resize it, and want to send the resulting, smaller image.


I don't want to keep the smaller copy of the image on the phone, as that's just a waste of space, and I'd have to handle creating the smaller image when the larger one is chosen, and deleting both the larger and smaller ones when they're no longer referenced.


I thought about using sendMessageData, but that only lets me send NSData, and doesn't include any way of telling the Watch app that this new bit of data it's receiving is for a specific item, i.e. there's no extra metadata I can send to say this is the image for event X.


I cannot include the images as data in the application context, as the payload is too large.


There must be some easy way of sending data across. You say sendMessage is intended for small messages, but allow us to send NSData. What does Apple consider "small"? Is 188kb really that large?


Thanks.

Sorry to hear you have had difficulty with the transferFile API. It'd be great if you filed a bug report requesting sample code showing how to use this API (report back with the radar number so I can make sure it gets to the right place promptly!).


As for where to move the file once received depends on the intended lifetime of the file. If you only need it for a short amount of time NSTemporaryDirectory() might be a good place, otherwise perhaps NSCachesDirectory; though I can imagine a subdirectory called com.foo.whensthat in the NSApplicationSupportDirectory might be the most appropriate place in your case as it sounds like you'd want to hold on to the image on the watch side.


On the sending side you should persist the small version of the image to WCSession's watchDirectoryURL as that will get cleaned up for you if the user uninstalls your watch app or unpairs his watch.


The transferFile API should work just fine; if you are finding otherwise a bug report with an included sample project will be the best path forward.


Hope this helps!