New issue
Advanced search Search tips

Issue 676163 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Dec 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug-Regression



Sign in to add a comment

Since change to 55 the DataTransferItem.getAsFile function has changed, breaking pasting from some apps

Reported by r...@atomic.io, Dec 20 2016

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36

Steps to reproduce the problem:
Unfortunately I've only been able to reproduce this with the SketchApp design application so far https://www.sketchapp.com/

1. Draw a rectangle in Sketch.

2. Copy it to the clipboard in Sketch 

3. Paste it into a google doc in v54 and it will paste

4. Paste it into a google doc in v55 and it will not work 

What is the expected behavior?
It should paste the rectangle

What went wrong?
The DataTransferItem.getAsFile function is returning null rather than a blob despite the item apparently existing in the item list with the same type/kind etc (image/png). When inspecting the contents of the item I can't detect any difference between v54 and v55

This is still a problem in v57 (Canary) too.

Did this work before? Yes 54

Does this work in other browsers? Yes

Chrome version: 55  Channel: stable
OS Version: OS X 10.10.2
Flash Version: Shockwave Flash 24.0 r0

I'm assuming this may be broken for other apps besides Sketch, however it does not appear to be a problem with photoshop or the OSX screenshot tool.
 

Comment 1 by tkent@chromium.org, Dec 21 2016

Labels: Needs-Bisect

Comment 2 by ajha@chromium.org, Dec 21 2016

Labels: M-55
Cc: kkaluri@chromium.org
Labels: -M-55 -Needs-Bisect hasbisect-per-revision ReleaseBlock-Stable M-57
Owner: erikc...@chromium.org
Status: Assigned (was: Unconfirmed)
Able to reproduce this issue on Mac 10.12.2 on chrome stable version 55.0.2883.87 and also in current canary version #57.0.2958.0
Issue is broken in M55. 

Bisect Info:
===========

Good build : 55.0.2844.0,  Revision Range -415023
Bad build  : 55.0.2845.0,  Revision Range -415522

After executing the per-revision-bisect script, i got the following CL's between good and bad build versions
===========================================
https://chromium.googlesource.com/chromium/src/+log/94a2445fd9dacd5d11f906cec52b85b24b929146..7917e6ae37f5f838299aaaa65f785a0e657bc5bd

The suspecting Change Log is :
-----------
https://chromium.googlesource.com/chromium/src/+/7917e6ae37f5f838299aaaa65f785a0e657bc5bd

From the above CL suspecting the below change
---------------------------
Review-Url: https://codereview.chromium.org/2276183002

erikchen @- Could you please look into this issue, if it's related to your change?  if not could you please help us to reassign this issue to the right owner.


Observations: This behavior doesn't work in Chrome Canary, Chrome Stable (55), Safari 10, or Firefox 50. It worked on Firefox 49.
Somehow, Sketch is managing to get an NSPDFImageRep into the clipboard. Something along the lines of:
"""
image: <NSImage 0x7fc14d107710 Size={99, 101} Reps=(
    "NSPDFImageRep 0x7fc14d104e50 Size={99, 101} ColorSpace=NSCalibratedRGBColorSpace BPS=0 Pixels=0x0 Alpha=NO"
)>
"""

notice that pixels=0x0

This causes my newly added code in ui/base/clipboard/clipboard_mac.mm [which assumes pixels != 0 to hit a DCHECK]. 

I haven't been able to write a test yet that demonstrates this since when I write the NSImage to the clipboard, I get:
"""<NSImage 0x7fc14d306ea0 Size={99, 101} Reps=(
    "NSBitmapImageRep 0x7fc14d307ad0 Size={99, 101} ColorSpace=(not yet loaded) BPS=8 BPP=(not yet loaded) Pixels=99x101 Alpha=YES Planar=NO Format=(not yet loaded) CurrentBacking=nil (faulting) CGImageSource=0x7fc14d306a60",
    "NSBitmapImageRep 0x7fc14d308f60 Size={99, 101} ColorSpace=(not yet loaded) BPS=8 BPP=(not yet loaded) Pixels=198x202 Alpha=YES Planar=NO Format=(not yet loaded) CurrentBacking=nil (faulting) CGImageSource=0x7fc14d306a60",
    "NSBitmapImageRep 0x7fc14d30a180 Size={99, 101} ColorSpace=(not yet loaded) BPS=8 BPP=(not yet loaded) Pixels=297x303 Alpha=YES Planar=NO Format=(not yet loaded) CurrentBacking=nil (faulting) CGImageSource=0x7fc14d306a60"
)>
"""
Ah, NSPasteboardTypePDF.

Already, test/CL coming up. Note that this doesn't actually solve the behavior change requested by the reporter. That appears to be an issue either with docs, or with HTML/CSS spec.
Project Member

Comment 7 by bugdroid1@chromium.org, Dec 22 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/9597b569111b84dd7d96c04644e75783c6211547

commit 9597b569111b84dd7d96c04644e75783c6211547
Author: erikchen <erikchen@chromium.org>
Date: Thu Dec 22 18:47:48 2016

Fix reading PDF images from NSPasteboard.

PDF images have a single representation [NSPDFImageRep] with a size but not
pixelSize. The previous code assumes that pixelSize would always be valid.

BUG= 676163 

Review-Url: https://codereview.chromium.org/2599643002
Cr-Commit-Position: refs/heads/master@{#440458}

[modify] https://crrev.com/9597b569111b84dd7d96c04644e75783c6211547/ui/base/clipboard/clipboard_mac.h
[modify] https://crrev.com/9597b569111b84dd7d96c04644e75783c6211547/ui/base/clipboard/clipboard_mac.mm
[modify] https://crrev.com/9597b569111b84dd7d96c04644e75783c6211547/ui/base/clipboard/clipboard_mac_unittest.mm

Status: Fixed (was: Assigned)
Pasting images from Sketch now works in google docs for me (when my patch is included).
Labels: TE-Verified-57.0.2970.0 TE-Verified-M57
Verified on Mac OS 10.12.2 using chrome dev M57 #57.0.2970.0 and issue is fixed.

Able to paste the rectangle drawn in sketch to google doc .

Attached screencast for reference.

Adding TE-Verified labels.

Thanks!
676163.mp4
879 KB View Download

Sign in to add a comment