Closed Bug 1736177 Opened 4 years ago Closed 4 years ago

Add initial implementation of OffscreenCanvas + WebGL

Categories

(Core :: Graphics: CanvasWebGL, defect, P3)

defect

Tracking

()

RESOLVED FIXED
97 Branch
Tracking Status
firefox97 --- fixed

People

(Reporter: aosmond, Assigned: aosmond)

References

Details

(Keywords: dev-doc-needed)

Crash Data

Attachments

(12 files, 1 obsolete file)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

The OffscreenCanvas WebIDL has fallen behind the standard. We need to update it to be more current before we can hope to ship this feature.

Assignee: nobody → aosmond
Status: NEW → ASSIGNED

This patch contains no functional changes but sets us up for refactoring
in a later part in this series. It also helps silence a bunch of
compiler warnings.

This patch contains no functional changes but sets us up for refactoring
in a later part in this series.

This patch separates out a class, nsICanvasRenderingDisplay, for use on
the display list building pipeline. nsICanvasRenderingContextInternal
inherits from this and all of the canvas contexts implement the APIs the
same as today for display purposes. This will make it easier to provide
a display only class for OffscreenCanvas.

It also standardizes on SupportsWeakPtr/WeakPtr instead of mixing in C++
standard library versions.

Workers require all runnables to implement nsIDiscardableRunnable. This
is because the worker may want to terminate after going out of scope,
and want to discard any pending events. It should be safe to simply drop
any WebGL related events since we are going to tear down the context /
actors as well.

Also ensure that we record dirty events even without an associated
HTMLCanvasElement so that the OffscreenCanvas is notified properly.

Right now, if we wanted to get a snapshot of an OffscreenCanvas context
on a worker thread from the main thread, we would need to block the main
thread on the worker thread, and from the worker thread, issue a sync
IPC call get the front buffer snapshot.

This patch adds an alternative which allows the main thread to go
directly to the canvas owning thread in the compositor process to get
the snapshot, thereby bypassing the worker thread in content process
entirely. All it needs as the unique ID of the CanvasManagerChild
instance, and the protocol ID of the WebGLChild instance.

This will be used for Firefox screenshots, New Tab tiles, and printing.

This helper class manages the necessary state to facilitate the display
pipeline for an OffscreenCanvas created through HTMLCanvasElement's
transferControlToOffscreen.

This patch integrates OffscreenCanvasDisplayHelper with
HTMLCanvasElement, OffscreenCanvas and nsDisplayCanvas to allow
asynchronous display of an OffscreenCanvas.

Summary: Update OffscreenCanvas webidl interface → Add initial implementation of OffscreenCanvas + WebGL
Crash Signature: [@ libxul.so@0x2845535 | libxul.so@0x2854e2a | libxul.so@0x8f4197 | libxul.so@0x205b5eb | libxul.so@0x205b6a2 | libxul.so@0x5890b9f | libxul.so@0x1d54bda | libxul.so@0x6badf4f | libxul.so@0x1fe03e7 | libxul.so@0x1fe01ef | libxul.so@0x3d41f45 | libxul.so@0…
Crash Signature: libxul.so@0...] [@ mozilla::dom::WorkerPrivate::MaybeWrapAsWorkerRunnable] → libxul.so@0...] [@ mozilla::dom::WorkerPrivate::MaybeWrapAsWorkerRunnable]
Component: Canvas: 2D → Canvas: WebGL
Attachment #9250062 - Attachment description: Bug 1736177 - Part 13. Fix/mark more OffscreenCanvas related tests as passing. → Bug 1736177 - Part 12. Fix/mark more OffscreenCanvas related tests as passing.

Comment on attachment 9250061 [details]
Bug 1736177 - Part 12. Make HTMLCanvasElement's toDataURL to work with OffscreenCanvas.

Revision D130788 was moved to bug 1744854. Setting attachment 9250061 [details] to obsolete.

Attachment #9250061 - Attachment is obsolete: true
Pushed by aosmond@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/db2347ee8147 Part 1. Rename CanvasRenderingContextHelper::GetContext to GetOrCreateContext. r=jgilbert https://hg.mozilla.org/integration/autoland/rev/70aff7fcd001 Part 2. Add variants of CanvasRenderingContextHelper::ToBlob. r=jgilbert https://hg.mozilla.org/integration/autoland/rev/4a34124d5f4e Part 3. Update OffscreenCanvas WebIDL to be more current. r=dom-worker-reviewers,jgilbert,smaug https://hg.mozilla.org/integration/autoland/rev/f400c75c5829 Part 4. Expose missing WebGL interfaces to workers. r=dom-worker-reviewers,jgilbert,smaug https://hg.mozilla.org/integration/autoland/rev/86f6f6d86c6c Part 5. Implement OffscreenCanvas::ConvertToBlob. r=jgilbert https://hg.mozilla.org/integration/autoland/rev/bf588f8ffcf1 Part 6. Refactor WebRender display list building integration. r=kvark,jgilbert https://hg.mozilla.org/integration/autoland/rev/d55f1ee88bb9 Part 7. Remove some main thread dependencies from (Client)WebGLContext. r=jgilbert https://hg.mozilla.org/integration/autoland/rev/6d6c78c31c28 Part 8. Remove unused visibility observer from HTMLCanvasElement. r=jgilbert https://hg.mozilla.org/integration/autoland/rev/2610d4464ad5 Part 9. Add plumbing to snapshot worker canvas contexts from the main thread. r=jgilbert,ipc-reviewers,nika https://hg.mozilla.org/integration/autoland/rev/49f8b4205a46 Part 10. Add OffscreenCanvasDisplayHelper implementation. r=jgilbert https://hg.mozilla.org/integration/autoland/rev/5be8557c4721 Part 11. Plumb in OffscreenCanvasDisplayHelper. r=jgilbert https://hg.mozilla.org/integration/autoland/rev/828633114de2 Part 12. Fix/mark more OffscreenCanvas related tests as passing. r=jgilbert

I think I've gotten the outstanding issues resolved except for the WebRTC one which seems to be out of left field. But it is failing consistently and it is WebGL, so it is plausible I broke something.

Flags: needinfo?(aosmond)

Jib, any ideas here?

Flags: needinfo?(jib)

It appears that it is part 7 that caused it. Perhaps it is related to the changes in ClientWebGLContext::MarkCanvasDirty, as the behaviour is slightly different for setting mCapturedFrameInvalidated to true, and the test case is capture related.

Looks like that's it.

Flags: needinfo?(jib)
Pushed by aosmond@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5ad078db7d7b Part 1. Rename CanvasRenderingContextHelper::GetContext to GetOrCreateContext. r=jgilbert https://hg.mozilla.org/integration/autoland/rev/6cbaee34e535 Part 2. Add variants of CanvasRenderingContextHelper::ToBlob. r=jgilbert https://hg.mozilla.org/integration/autoland/rev/25ca519aa6fc Part 3. Update OffscreenCanvas WebIDL to be more current. r=dom-worker-reviewers,jgilbert,smaug https://hg.mozilla.org/integration/autoland/rev/f5814b14480c Part 4. Expose missing WebGL interfaces to workers. r=dom-worker-reviewers,jgilbert,smaug https://hg.mozilla.org/integration/autoland/rev/e8c475e9e8e4 Part 5. Implement OffscreenCanvas::ConvertToBlob. r=jgilbert https://hg.mozilla.org/integration/autoland/rev/26e52340910f Part 6. Refactor WebRender display list building integration. r=kvark,jgilbert https://hg.mozilla.org/integration/autoland/rev/2859a91f3a73 Part 7. Remove some main thread dependencies from (Client)WebGLContext. r=jgilbert https://hg.mozilla.org/integration/autoland/rev/047bcbf3769f Part 8. Remove unused visibility observer from HTMLCanvasElement. r=jgilbert https://hg.mozilla.org/integration/autoland/rev/7e5591aad25a Part 9. Add plumbing to snapshot worker canvas contexts from the main thread. r=jgilbert,ipc-reviewers,nika https://hg.mozilla.org/integration/autoland/rev/7b946576bafa Part 10. Add OffscreenCanvasDisplayHelper implementation. r=jgilbert https://hg.mozilla.org/integration/autoland/rev/bc1b6e82d67f Part 11. Plumb in OffscreenCanvasDisplayHelper. r=jgilbert https://hg.mozilla.org/integration/autoland/rev/a441516deed7 Part 12. Fix/mark more OffscreenCanvas related tests as passing. r=jgilbert
Regressions: 1745384
Keywords: dev-doc-needed

Adding dev-doc-needed keyword so I can track this for MDN updates

Regressions: 1747009
Regressions: 1755698
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: