Closed Bug 1494588 Opened 7 years ago Closed 5 years ago

Drag&drop of multiple attachments creates duplicates

Categories

(Thunderbird :: Message Reader UI, defect)

Unspecified
macOS
defect
Not set
normal

Tracking

(thunderbird_esr60+, thunderbird_esr68+, thunderbird_esr78 fixed, thunderbird79 fixed)

RESOLVED FIXED
Thunderbird 80.0
Tracking Status
thunderbird_esr60 + ---
thunderbird_esr68 + ---
thunderbird_esr78 --- fixed
thunderbird79 --- fixed

People

(Reporter: starless, Assigned: khushil324)

References

Details

(Keywords: regression)

Attachments

(1 file, 2 obsolete files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36 Steps to reproduce: In TB 60.0b11 on macOS 10.13.6, upon receiving a message with multiple (4) attachments, I opened the "attachments area" below the message preview to show all attached files, then I selected them all, and finally dragged them and dropped them into a Finder window. Actual results: In the destination folder 16 files were created, instead of 4. Each attachment was saved 4 times, its duplicates are named appending "-1", "-2", "-3" to the original file name. Expected results: Only 4 files with the original attachments names should have been created.
Does it also happen with THunderbird started in safe mode?
Flags: needinfo?(starless)
Yes the same happens also in safe mode. And for the record, it does not happen only with a specific message: it happens with any message having multiple attachments.
Flags: needinfo?(starless)
> In TB 60.0b11 on macOS 10.13.6 In what version did this last work?
Flags: needinfo?(starless)
I'm not able to answer this question because it's just a few months since I started using TB on Mac daily. It is surely happening since a few betas, but I do not know about older versions.
Flags: needinfo?(starless)
Needs love from those who know Mac
Can confirm this is reproducible for me in TB 60.2.1 on OSX 10.13.6.
Thanks. Perhaps then this is a regression / worked in version 52. Not sure which component to put this.
Component: Untriaged → Message Reader UI
Works OK on Windows. Hmm, you could look at this for us? Is Markus still active (mstange@themasta.com)? Arshad is a Mac person, but he's got other things to do. Alice, do you also find regressions on Mac?
Flags: needinfo?(vseerror)
Flags: needinfo?(mkmelin+mozilla)
Flags: needinfo?(alice0775)
Keywords: regression
(I won't have time to look at this, plus I don't have a Mac)
Flags: needinfo?(vseerror)
I don't have a Mac too...
Flags: needinfo?(alice0775)
Didn't somebody report it's not working at all on mac anymore? xref bug 270292 to find the related code for debugging.
Flags: needinfo?(mkmelin+mozilla)
OS: Unspecified → Mac OS X
I've tested this issue with different versions of Thunderbird on macOS Mojave. Seems the issue was introduced with TB 53. 60.0 - issue 58.0b3 - issue 57.0b2 - issue 56.0b4 - issue 55.0b2 - issue 54.0b3 - issue 53.0b2 - issue 52.9.1 - no issue, working
Well, that broke ages ago and no beta user ever complained :-((( Markus, do you still help out in TB with Mac issues? Also NI'ing a few other people known to have Macs.
Flags: needinfo?(stefanh)
Flags: needinfo?(ntim.bugs)
Flags: needinfo?(mstange)
I can reproduce this, seems like you get n^2 files for n attachments you drag.
Flags: needinfo?(ntim.bugs)
Flags: needinfo?(ntim.bugs)
Flags: needinfo?(ntim.bugs)
I tried to find a regression range using `mozregression --app thunderbird`, but all the builds around 50-52 crash on MacOS.
(In reply to Alice0775 White from comment #15) > I can reproduce the issue on Tb60.2.1 Linux Mint. sorry, this is wrong. pls ignore the comment#15
(In reply to Nomis101 from comment #12) > I've tested this issue with different versions of Thunderbird on macOS > Mojave. Seems the issue was introduced with TB 53. ... > 53.0b2 - issue > 52.9.1 - no issue, working Is there an easy way to get a diff between 52.9.1 and 53.0b2? I was hoping to be able to compare two versions in DXR but my DXR-fu is weak. :-/
(In reply to Tim Nguyen :ntim (please use needinfo?) from comment #16) > ... but all the builds around 50-52 crash on MacOS. If comment #12 is correct, it would be best to look at thhe mozilla53 cycle (2016-11-14 - 2017-01-23). To my knowledge, there is no DXR diff, you colud only look at there changelog of the respective Mac files that handle drag&drop, like this one: https://hg.mozilla.org/mozilla-central/log/tip/widget/cocoa/nsDragService.mm

Working with MAC High Sierra. This error started with Thunderbird 60.xxx. Before copying multiple attachments to a folder did not cause duplicates.

Alex, you have a Mac, can you please check this.

Flags: needinfo?(stefanh)
Flags: needinfo?(mstange)
Flags: needinfo?(alessandro)

I can confirm the issue.
I tested this on both v60.7.2 and trunk on macos Mojave.

Dragging and dropping 3 attachments at once, with 3 difference sizes and file types, resulted in a total of 9 attachments downloaded on the desktop. So it seems the number of times a single file is downloaded is equal to the number of attachments selected.

I see if I have some capacity this week since I'm fixing a couple of regressions in the acctachment list area.

Flags: needinfo?(alessandro)

I can also confirm this on MacOS 10.14.6 (Mojave) and Thunderbird 68.4.1 and 68.4.2. If you drag multiple attachment files to a Finder window it will always create n^2 files instead of n.

Can someone please fix this, this is really annoying.

Magnus?

Flags: needinfo?(mkmelin+mozilla)

Khushil is working on dnd currently for bug 1226362. Please have a look at this at the same time.

Assignee: nobody → khushil324
Flags: needinfo?(mkmelin+mozilla)

This is kind of a hack. This issue is coming from Mozilla Central.
This line should get called n times instead of n^2 times where n is the total number of attachments: https://searchfox.org/mozilla-central/source/widget/nsTransferable.cpp#248,256
Anyone has any idea?

Attachment #9130079 - Flags: review?(mkmelin+mozilla)

Where do the n^2 calls come from? I don't see a loop in the M-C code. Can you attach the debugger to it?

Comment on attachment 9130079 [details] [diff] [review] Bug-1494588_dnd-of-attachments-creates-duplicates-osx-0.patch Review of attachment 9130079 [details] [diff] [review]: ----------------------------------------------------------------- I think we need to find the cause and fix that instead. I don't understand what is called more than N times. What does it output if you add printfs for each of the functions you mark, like printf("xxx nsTransferable::GetTransferData aFlavor=%s\n", aFlavor.get()); and similar for the other two
Attachment #9130079 - Flags: review?(mkmelin+mozilla) → review-

Here is the flow of the whole event:

  1. When attachments get dragged, setupDataTransfer is called to add the data in event.dataTransfer: https://searchfox.org/comm-central/source/mail/base/content/mailCore.js#841, https://searchfox.org/comm-central/source/mail/base/content/msgHdrView.js#3392

  2. nsFlavorDataProvider object is saved as "application/x-moz-file-promise" event.dataTransfer. nsFlavorDataProvider interface has getFlavorData method. When you drop any item in the local machine, this should get the call(only once) and it will save the file into the local machine with the help of the saved data in event.dataTransfer: https://searchfox.org/comm-central/source/mail/base/content/mailCore.js#841,891,903,940

  3. nsFlavorDataProvider interface is coming from here: https://searchfox.org/mozilla-central/source/widget/nsITransferable.idl#80

  4. I checked with all the nsFlavorDataProvider instances. When you drop a file in the local machine, nsTransferable::GetTransferData is getting called and we have call to dataProvider->GetFlavorData(this, aFlavor, getter_AddRefs(dataBytes)); there: https://searchfox.org/mozilla-central/source/widget/nsTransferable.cpp#248,253

  5. I used printf statements to debug the code in nsTransferable::GetTransferData just like printf("xxx nsTransferable::GetTransferData aFlavor=%s\n", aFlavor.get()); It was getting printed n^2 times always with aFlavor.get() is equal to application/x-moz-file-promise. I think once it's done, it should not pass the if statemenet here: https://searchfox.org/mozilla-central/source/widget/nsTransferable.cpp#253. But I don't know what does this if statement do/check.

It's working on MacOS. Can you check if it's not breaking anything on Linux?

Attachment #9130079 - Attachment is obsolete: true
Attachment #9160378 - Flags: review?(mkmelin+mozilla)
Status: NEW → ASSIGNED
Comment on attachment 9160378 [details] [diff] [review] Bug-1494588_dnd-multiple-items-mac-0.patch Review of attachment 9160378 [details] [diff] [review]: ----------------------------------------------------------------- ::: mail/base/content/mailCore.js @@ +949,4 @@ > ); > aData.value = destFilePath.QueryInterface(Ci.nsISupports); > } > + aTransferable.removeDataFlavor("application/x-moz-file-promise"); Seems like a hack.But maybe we could still do it as ``` if (AppConstants.platform == "macosx") { // Workaround dnd of multiple attachments creating duplicates. See bug 1494588. aTransferable.removeDataFlavor("application/x-moz-file-promise"); } ```
Attachment #9160378 - Flags: review?(mkmelin+mozilla)
Attachment #9160378 - Attachment is obsolete: true
Attachment #9160599 - Flags: review?(mkmelin+mozilla)
Attachment #9160599 - Flags: review?(mkmelin+mozilla) → review+
Target Milestone: --- → Thunderbird 80.0

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/4b7f17978f58
Fix drag & drop of multiple attachments creating duplicates in MacOS. r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED

Please don't forget uplift here.

Flags: needinfo?(mkmelin+mozilla)
Flags: needinfo?(khushil324)
Comment on attachment 9160599 [details] [diff] [review] Bug-1494588_dnd-multiple-items-mac-1.patch [Approval Request Comment] User impact if declined: per summary Testing completed (on c-c, etc.): Risk to taking this patch (and alternatives if risky): Quite contained fix, so not very risky. Though it's not well understood why it happens.
Flags: needinfo?(mkmelin+mozilla)
Flags: needinfo?(khushil324)
Attachment #9160599 - Flags: approval-comm-esr78?
Attachment #9160599 - Flags: approval-comm-beta?
Comment on attachment 9160599 [details] [diff] [review] Bug-1494588_dnd-multiple-items-mac-1.patch Approved for beta Eckard, can you test this when we smoketest beta?
Flags: needinfo?(de.berberich)
Attachment #9160599 - Flags: approval-comm-beta? → approval-comm-beta+
Comment on attachment 9160599 [details] [diff] [review] Bug-1494588_dnd-multiple-items-mac-1.patch Approved for esr78
Attachment #9160599 - Flags: approval-comm-esr78? → approval-comm-esr78+

(In reply to Wayne Mery (:wsmwk) from comment #37)

Comment on attachment 9160599 [details] [diff] [review]
Bug-1494588_dnd-multiple-items-mac-1.patch

Approved for beta

Eckard, can you test this when we smoketest beta?

I can't reproduce this issue in TB 79.0b3.

Flags: needinfo?(de.berberich)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: