Closed Bug 1224855 Opened 9 years ago Closed 9 years ago

Crash in UIKit: -[UIPasteboard(UIPasteboardDataExtensions) setImage:]

Categories

(Firefox for iOS :: General, defect)

All
iOS
defect
Not set
critical

Tracking

()

VERIFIED FIXED
Tracking Status
fxios-v1.1 --- affected
fxios 1.3+ ---

People

(Reporter: aaronmt, Assigned: bnicholson)

Details

(Keywords: crash)

Attachments

(1 file)

Last Exception Backtrace:
0   CoreFoundation                	0x1862f4f48 __exceptionPreprocess + 124 (NSException.m:162)
1   libobjc.A.dylib               	0x19aea7f80 objc_exception_throw + 56 (objc-exception.mm:531)
2   CoreFoundation                	0x1862f4e90 +[NSException raise:format:] + 120 (NSException.m:140)
3   UIKit                         	0x18bdbde5c -[UIPasteboard(UIPasteboardDataExtensions) setImage:] + 168 (UIPasteboard.m:620)
4   Client                        	0x10020d164 specialized BrowserViewController.(contextMenuHelper(BrowserViewController) -> (ContextMenuHelper, didLongPressElements : ContextMenuHelper.Elements, gestureRecognizer : UILongPressGestureRecognizer) -> ()).(closure #5).(closure #2) + 428 (BrowserViewController.swift:2176)
5   Alamofire                     	0x1018bcb68 Request.(response(Request) -> (queue : OS_dispatch_queue?, completionHandler : (NSURLRequest?, NSHTTPURLResponse?, NSData?, NSError?) -> ()) -> Self).(closure #1).(closure #1) + 236 (ResponseSerialization.swift:85)
6   libdispatch.dylib             	0x19b6c56e8 _dispatch_call_block_and_release + 24 (init.c:760)
7   libdispatch.dylib             	0x19b6c56a8 _dispatch_client_callout + 16 (object.m:506)
8   libdispatch.dylib             	0x19b6cadb0 _dispatch_main_queue_callback_4CF + 1844 (inline_internal.h:1063)
9   CoreFoundation                	0x1862ac1f8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 (CFRunLoop.c:1613)
10  CoreFoundation                	0x1862aa060 __CFRunLoopRun + 1628 (CFRunLoop.c:2718)
11  CoreFoundation                	0x1861d8ca0 CFRunLoopRunSpecific + 384 (CFRunLoop.c:2814)
12  GraphicsServices              	0x191414088 GSEventRunModal + 180 (GSEvent.c:2245)
13  UIKit                         	0x18b8f0ffc UIApplicationMain + 204 (UIApplication.m:3665)
14  Client                        	0x1000a5e9c main + 332 (main.swift:22)
15  libdyld.dylib                 	0x19b6f68b8 start + 4 (start_glue.s:80)
Brian, any clues?
Flags: needinfo?(bnicholson)
Looking at our Copy Image code, I see a few different issues:

1. In the Alamofire response, we do application.endBackgroundTask() only if the pasteboard string equals the copied string. We do this check to prevent replacing the pasteboard contents in case it's changed after any long-running image fetching, but ending the background task should be done unconditionally.

2. UIImage(data: NSData) can return nil if the image creation fails for whatever reason, and we don't guard against this. I tested explicitly assigning pasteBoard.image = nil, and that caused the same crash reported in the bug, so I'm guessing that's the issue. Not sure why iOS allows setting a nil image if it's not supported!

3. Setting the image replaces the image URL text in the pasteboard. The iOS pasteboard supports multiple representations simultaneously for an item on the pasteboard, so in this case, the pasteboard should hold both the image and its URL (e.g., for when pasting into text fields). This is consistent with Safari.
Assignee: nobody → bnicholson
Status: NEW → ASSIGNED
Flags: needinfo?(bnicholson)
Attachment #8689788 - Flags: review?(etoop)
Comment on attachment 8689788 [details] [review]
Link to Github pull-request: https://github.com/mozilla/firefox-ios/pull/1285

See comments about incorrect file type being displayed in iMessage/Messages when copying image of type JPEG.
Attachment #8689788 - Flags: feedback+
Comment on attachment 8689788 [details] [review]
Link to Github pull-request: https://github.com/mozilla/firefox-ios/pull/1285

Updated with commentary.
Attachment #8689788 - Flags: feedback+
STR crash, for the sake of completeness:
1) Go to http://people.mozilla.org/~bnicholson/test/image.html.
2) Long press and choose Copy Image.
Keywords: steps-wanted
Comment on attachment 8689788 [details] [review]
Link to Github pull-request: https://github.com/mozilla/firefox-ios/pull/1285

Yup, this last patch fixes it and renders the right image with the correct URL fallback.
Attachment #8689788 - Flags: review?(etoop) → review+
Master: 60a3b28
v1.x: a0be117
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Reproduced the issue on version 1.2 build 1206 using Iphone 6 (IOS 9.1). Verified as fixed on version 1.3 build 1308.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: