Closed Bug 1755863 Opened 2 years ago Closed 2 years ago

Improve performance of `Clipboard::Read` by reading data from clipboard asynchronously

Categories

(Core :: DOM: Copy & Paste and Drag & Drop, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
105 Branch
Tracking Status
firefox105 --- fixed

People

(Reporter: mbrodesser-Igalia, Assigned: edgar)

References

(Blocks 2 open bugs)

Details

(Keywords: perf)

Attachments

(5 files, 1 obsolete file)

Keywords: perf

Hi Neil, in this bug, we would like to use async IPC to get the clipboard data from OS for clipboard.read() (we have done a similar thing for clipboard.readText() in bug 1472338). To achieve that, I introduce some async API in nsIClipboard, and make web Clipboard implementation use those nsIClipboard API directly without going through DataTransfer. Would you mind taking a look? It would be appreciated if you could give some feedback on the WIP patches.

Flags: needinfo?(enndeakin)

I can take a look in more detail if you like, but some initial feedback:

  1. The widget changes in the first patch don't seem particularly necessary. The apis that get formats/flavours aren't asynchronous in any os, that I know of, nor should it have any performance issue, so I think we only need to use a asynchronous api here to wait for the format info to pass across our content to parent process boundary and can just use the existing clipboard methods in the parent process.
  2. Is the code in the third patch in ReadHelper intended to be limited to specific formats? Is this api limited in what formats it supports?
  3. We shouldn't be calling clipboard->AsyncGetData in the ClipboardItem constructor -- it should be called in ClipboardItem::GetType.

The general design looks ok though.

Flags: needinfo?(enndeakin)

(In reply to Neil Deakin from comment #7)

I can take a look in more detail if you like, but some initial feedback:

  1. The widget changes in the first patch don't seem particularly necessary. The apis that get formats/flavours aren't asynchronous in any os, that I know of, nor should it have any performance issue, so I think we only need to use a asynchronous api here to wait for the format info to pass across our content to parent process boundary and can just use the existing clipboard methods in the parent process.

But if we only use the asynchronous API in content process, which means we need to call different nsIClipboard API on parent process and content process in DOM clipboard code, which I would like to avoid doing so.

  1. Is the code in the third patch in ReadHelper intended to be limited to specific formats? Is this api limited in what formats it supports?

Yes, we intended to do that for now, Blink and Webkit only support those mime types on clipboard API, too. We could support more later if needed.

  1. We shouldn't be calling clipboard->AsyncGetData in the ClipboardItem constructor -- it should be called in ClipboardItem::GetType.

Actually, this is what we expect. Spec also defines the system clipboard data is read when read() is called, https://w3c.github.io/clipboard-apis/#dom-clipboard-read.

(In reply to Edgar Chen [:edgar] from comment #8)

(In reply to Neil Deakin from comment #7)

  1. The widget changes in the first patch don't seem particularly necessary. The apis that get formats/flavours aren't asynchronous in any os, that I know of, nor should it have any performance issue, so I think we only need to use a asynchronous api here to wait for the format info to pass across our content to parent process boundary and can just use the existing clipboard methods in the parent process.

But if we only use the asynchronous API in content process, which means we need to call different nsIClipboard API on parent process and content process in DOM clipboard code, which I would like to avoid doing so.

On a second thought, we could use the existing API to get formats/flavors first, we could do that later if we figure out it is necessary.

Attachment #9274889 - Attachment is obsolete: true
Attachment #9274890 - Attachment description: WIP: Bug 1755863 - Part 2: Add async API for getting data on nsIClipboard; → Bug 1755863 - Part 1: Add async API for getting data on nsIClipboard;
Attachment #9274890 - Attachment description: Bug 1755863 - Part 1: Add async API for getting data on nsIClipboard; → WIP: Bug 1755863 - Part 1: Add async API for getting data on nsIClipboard;
Attachment #9274891 - Attachment description: WIP: Bug 1755863 - Part 3: Use async nsClipboard API to implement clipboard.read(); → WIP: Bug 1755863 - Part 2: Use async nsClipboard API to implement clipboard.read();
Attachment #9274892 - Attachment description: WIP: Bug 1755863 - Part 4: Use async nsClipboard API to implement clipboard.readText(); → WIP: Bug 1755863 - Part 3: Use async nsClipboard API to implement clipboard.readText();
Assignee: nobody → echen
Attachment #9274890 - Attachment description: WIP: Bug 1755863 - Part 1: Add async API for getting data on nsIClipboard; → Bug 1755863 - Part 1: Add async API for getting data on nsIClipboard;
Attachment #9274891 - Attachment description: WIP: Bug 1755863 - Part 2: Use async nsClipboard API to implement clipboard.read(); → Bug 1755863 - Part 2-2: Use async nsClipboard API to implement clipboard.read();
Attachment #9274892 - Attachment description: WIP: Bug 1755863 - Part 3: Use async nsClipboard API to implement clipboard.readText(); → Bug 1755863 - Part 3: Use async nsClipboard API to implement clipboard.readText();
Attachment #9274890 - Attachment description: Bug 1755863 - Part 1: Add async API for getting data on nsIClipboard; → Bug 1755863 - Part 1: Add async API for getting data on nsIClipboard; r?NeilDeakin
Attachment #9282651 - Attachment description: Bug 1755863 - Part 2-1: Make ItemEntry a reference counted object; → Bug 1755863 - Part 2-1: Make ItemEntry a reference counted object; r?NeilDeakin
Attachment #9274891 - Attachment description: Bug 1755863 - Part 2-2: Use async nsClipboard API to implement clipboard.read(); → Bug 1755863 - Part 2-2: Use async nsClipboard API to implement clipboard.read(); r?NeilDeakin
Attachment #9274892 - Attachment description: Bug 1755863 - Part 3: Use async nsClipboard API to implement clipboard.readText(); → Bug 1755863 - Part 3: Use async nsClipboard API to implement clipboard.readText(); r?NeilDeakin!,mbrodesser!
Attachment #9282651 - Attachment description: Bug 1755863 - Part 2-1: Make ItemEntry a reference counted object; r?NeilDeakin → Bug 1755863 - Part 2-1: Make ItemEntry a reference counted object; r?NeilDeakin,nika
Attachment #9274891 - Attachment description: Bug 1755863 - Part 2-2: Use async nsClipboard API to implement clipboard.read(); r?NeilDeakin → Bug 1755863 - Part 2-2: Use async nsClipboard API to implement clipboard.read(); r?NeilDeakin!,nika!
Blocks: 1778201
Attachment #9282651 - Attachment description: Bug 1755863 - Part 2-1: Make ItemEntry a reference counted object; r?NeilDeakin,nika → Bug 1755863 - Part 3-1: Make ItemEntry a reference counted object; r?NeilDeakin,nika
Attachment #9274891 - Attachment description: Bug 1755863 - Part 2-2: Use async nsClipboard API to implement clipboard.read(); r?NeilDeakin!,nika! → Bug 1755863 - Part 3-2: Use async nsClipboard API to implement clipboard.read(); r?NeilDeakin!,nika!
Attachment #9274892 - Attachment description: Bug 1755863 - Part 3: Use async nsClipboard API to implement clipboard.readText(); r?NeilDeakin!,mbrodesser! → Bug 1755863 - Part 4: Use async nsClipboard API to implement clipboard.readText(); r?NeilDeakin!,mbrodesser!
Pushed by echen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/65e1dba3f3ec
Part 1: Add async API for getting data on nsIClipboard; r=geckoview-reviewers,NeilDeakin,m_kato,nika
https://hg.mozilla.org/integration/autoland/rev/b318f0bf426e
Part 2: Add async API/IPC for getting matching data flavors from clipboard; r=nika,geckoview-reviewers,m_kato
https://hg.mozilla.org/integration/autoland/rev/1c15d67cce05
Part 3-1: Make ItemEntry a reference counted object; r=nika
https://hg.mozilla.org/integration/autoland/rev/4e8b144ba280
Part 3-2: Use async nsClipboard API to implement clipboard.read(); r=NeilDeakin,nika
https://hg.mozilla.org/integration/autoland/rev/2102746fdbcb
Part 4: Use async nsClipboard API to implement clipboard.readText(); r=NeilDeakin,mbrodesser
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: