Closed Bug 1444434 Opened 6 years ago Closed 5 years ago

Capture profiler screenshots in WebRender

Categories

(Core :: Graphics: WebRender, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
mozilla68
Tracking Status
firefox60 --- wontfix
firefox68 --- fixed

People

(Reporter: mstange, Assigned: barret)

References

Details

Attachments

(8 files, 1 obsolete file)

47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
Once the infrastructure from bug 1444430 is in place, we should add a way to automatically capture profiler screenshots from WebRender on every composite, using asynchronous readback and scaling on the GPU.
Attached patch wip from a year ago (obsolete) — Splinter Review

Here's a patch I found in my local tree. IIRC it captured screenshots as subrects of the window instead of scaling it down to the correct size.

Looks like I had to add a new function to the gleam crate, in order to readback from a PBO, because the existing wrapper functions around ReadPixels did not allow me to pass 0 as the size:

    fn read_pixels_pbo(&self, x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, pixel_type: GLenum) {
        unsafe {
            self.ffi_gl_.ReadPixels(x, y, width, height, format, pixel_type, ptr::null_mut());
        }
    }

gleam also seems to need map_buffer and unmap_buffer functions:

    fn map_buffer(&self, target: GLenum, access: GLenum, len: usize) -> Option<&[u8]> {
        unsafe {
            let p = self.ffi_gl_.MapBuffer(target, access);
            if p.is_null() {
                None
            } else {
                Some(slice::from_raw_parts(p as *const u8, len))
            }
        }
    }

    fn unmap_buffer(&self, target: GLenum) {
        unsafe {
            self.ffi_gl_.UnmapBuffer(target);
        }
    }
Assignee: nobody → brennie
Status: NEW → ASSIGNED
Attachment #9043083 - Attachment is obsolete: true
Pushed by gwatson@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/7c994bd123df
Bump webrender and webrender_bindings gleam dependency to 0.6.14 r=kvark
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla68
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Attachment #9051861 - Attachment description: Bug 1444434 - Add C bindings to the Renderer::get_screenshot_for_profiler_async and Renderer::map_and_recycle_screenshot APIs r?kvark → Bug 1444434 - Add C bindings to the Renderer::get_screenshot_async and Renderer::map_and_recycle_screenshot APIs r?kvark
Attachment #9051862 - Attachment description: Bug 1444434 - Submit screenshots to the Gecko profiler from WebRender r?kvark → Bug 1444434 - Submit screenshots to the Gecko profiler from WebRender r?kvark,mstange

Pushed by csabou@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/0bcf6edc8656
Optionally create PBOs with a backing buffer and store that size with the PBO r=kvark
https://hg.mozilla.org/integration/autoland/rev/ec2a81eea388
Capture screenshots for the Gecko profiler in WebRender r=kvark
https://hg.mozilla.org/integration/autoland/rev/af008ed0a5c2
Add infrastructure for reading back screenshots for the Gecko profiler to WebRender r=kvark
https://hg.mozilla.org/integration/autoland/rev/543708a1f683
Add C bindings to the Renderer::get_screenshot_async and Renderer::map_and_recycle_screenshot APIs r=kvark
https://hg.mozilla.org/integration/autoland/rev/d2c85db549ea
Submit screenshots to the Gecko profiler from WebRender r=kvark,mstange
https://hg.mozilla.org/integration/autoland/rev/13c0d857bf3c
Free the Gecko profiler screenshots structures in the WebRender renderer when profiling stops r=kvark

Keywords: checkin-needed

Backed out 6 changesets (bug 1444434) for build bustages

Backout: https://hg.mozilla.org/integration/autoland/rev/9ac40c5bc0087cf4651d673f9be4ab6dbeee8a7d

Failure push: https://treeherder.mozilla.org/#/jobs?repo=autoland&selectedJob=236209834&revision=13c0d857bf3c7cb5b21f25e2c35e1f2f3a57a4e2

Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=236209993&repo=autoland&lineNumber=13316

task 2019-03-26T21:43:10.907Z] 21:43:10 WARNING - [style 0.0.1] Warning: can't set binop_separator = Back, unstable features are only available in nightly channel.
[task 2019-03-26T21:43:10.907Z] 21:43:10 WARNING - [style 0.0.1] Warning: can't set match_block_trailing_comma = true, unstable features are only available in nightly channel.
[task 2019-03-26T21:43:10.907Z] 21:43:10 INFO - Compiling webrender_bindings v0.1.0 (/builds/worker/workspace/build/src/gfx/webrender_bindings)
[task 2019-03-26T21:43:10.909Z] 21:43:10 INFO - Running /builds/worker/workspace/build/src/sccache2/sccache /builds/worker/workspace/build/src/rustc/bin/rustc --crate-name webrender_bindings gfx/webrender_bindings/src/lib.rs --color never --crate-type lib --emit=dep-info,link -C opt-level=1 -C panic=abort -C debuginfo=2 -C debug-assertions=on -C metadata=f575e6447ee84572 -C extra-filename=-f575e6447ee84572 --out-dir /builds/worker/workspace/build/src/obj-firefox/aarch64-linux-android/debug/deps --target aarch64-linux-android -C linker=/builds/worker/workspace/build/src/build/cargo-linker -L dependency=/builds/worker/workspace/build/src/obj-firefox/aarch64-linux-android/debug/deps -L dependency=/builds/worker/workspace/build/src/obj-firefox/debug/deps --extern app_units=/builds/worker/workspace/build/src/obj-firefox/aarch64-linux-android/debug/deps/libapp_units-2c238c6791ff08f0.rlib --extern bincode=/builds/worker/workspace/build/src/obj-firefox/aarch64-linux-android/debug/deps/libbincode-4284c0a3d1fb654f.rlib --extern euclid=/builds/worker/workspace/build/src/obj-firefox/aarch64-linux-android/debug/deps/libeuclid-259d4256cdaf0833.rlib --extern fxhash=/builds/worker/workspace/build/src/obj-firefox/aarch64-linux-android/debug/deps/libfxhash-5df2a3608fd21001.rlib --extern gleam=/builds/worker/workspace/build/src/obj-firefox/aarch64-linux-android/debug/deps/libgleam-7386f2f457dccdea.rlib --extern log=/builds/worker/workspace/build/src/obj-firefox/aarch64-linux-android/debug/deps/liblog-3d9793507f73d5f9.rlib --extern nsstring=/builds/worker/workspace/build/src/obj-firefox/aarch64-linux-android/debug/deps/libnsstring-01a380012443019e.rlib --extern rayon=/builds/worker/workspace/build/src/obj-firefox/aarch64-linux-android/debug/deps/librayon-8650915392611019.rlib --extern thread_profiler=/builds/worker/workspace/build/src/obj-firefox/aarch64-linux-android/debug/deps/libthread_profiler-61617e9c78301b72.rlib --extern uuid=/builds/worker/workspace/build/src/obj-firefox/aarch64-linux-android/debug/deps/libuuid-5f1a2bc7b64d8ed3.rlib --extern webrender=/builds/worker/workspace/build/src/obj-firefox/aarch64-linux-android/debug/deps/libwebrender-ab0f3d1477d185af.rlib -C opt-level=2 -C debuginfo=2 -Dwarnings
[task 2019-03-26T21:43:10.909Z] 21:43:10 ERROR - error[E0432]: unresolved import webrender::units
[task 2019-03-26T21:43:10.909Z] 21:43:10 INFO - --> gfx/webrender_bindings/src/bindings.rs:23:13
[task 2019-03-26T21:43:10.910Z] 21:43:10 INFO - |
[task 2019-03-26T21:43:10.910Z] 21:43:10 INFO - 23 | api::, units::, ApiRecordingReceiver, AsyncPropertySampler, AsyncScreenshotHandle,
[task 2019-03-26T21:43:10.910Z] 21:43:10 INFO - | ^^^^^ could not find units in webrender
[task 2019-03-26T21:43:10.910Z] 21:43:10 ERROR - error[E0433]: failed to resolve: use of undeclared type or module DeviceIntSize
[task 2019-03-26T21:43:10.910Z] 21:43:10 INFO - --> gfx/webrender_bindings/src/bindings.rs:373:19
[task 2019-03-26T21:43:10.911Z] 21:43:10 INFO - |
[task 2019-03-26T21:43:10.911Z] 21:43:10 INFO - 373 | size: DeviceIntSize::new(self.width, self.height),
[task 2019-03-26T21:43:10.911Z] 21:43:10 INFO - | ^^^^^^^^^^^^^ use of undeclared type or module DeviceIntSize
[task 2019-03-26T21:43:10.911Z] 21:43:10 ERROR - error[E0433]: failed to resolve: use of undeclared type or module TexelRect
[task 2019-03-26T21:43:10.911Z] 21:43:10 INFO - --> gfx/webrender_bindings/src/bindings.rs:447:17
[task 2019-03-26T21:43:10.912Z] 21:43:10 INFO - |
[task 2019-03-26T21:43:10.912Z] 21:43:10 INFO - 447 | uv: TexelRect::new(image.u0, image.v0, image.u1, image.v1),
[task 2019-03-26T21:43:10.912Z] 21:43:10 INFO - | ^^^^^^^^^ use of undeclared type or module TexelRect
[task 2019-03-26T21:43:10.912Z] 21:43:10 ERROR - error[E0433]: failed to resolve: use of undeclared type or module FramebufferIntSize
[task 2019-03-26T21:43:10.913Z] 21:43:10 INFO - --> gfx/webrender_bindings/src/bindings.rs:652:27
[task 2019-03-26T21:43:10.913Z] 21:43:10 INFO - |
[task 2019-03-26T21:43:10.913Z] 21:43:10 INFO - 652 | match renderer.render(FramebufferIntSize::new(width, height)) {
[task 2019-03-26T21:43:10.914Z] 21:43:10 INFO - | ^^^^^^^^^^^^^^^^^^ use of undeclared type or module FramebufferIntSize
[task 2019-03-26T21:43:10.914Z] 21:43:10 ERROR - error[E0433]: failed to resolve: use of undeclared type or module DeviceIntRect
[task 2019-03-26T21:43:10.914Z] 21:43:10 INFO - --> gfx/webrender_bindings/src/bindings.rs:687:9
[task 2019-03-26T21:43:10.915Z] 21:43:10 INFO - |
[task 2019-03-26T21:43:10.915Z] 21:43:10 INFO - 687 | DeviceIntRect::new(
[task 2019-03-26T21:43:10.915Z] 21:43:10 INFO - | ^^^^^^^^^^^^^ use of undeclared type or module DeviceIntRect
[task 2019-03-26T21:43:10.915Z] 21:43:10 ERROR - error[E0433]: failed to resolve: use of undeclared type or module DeviceIntPoint
[task 2019-03-26T21:43:10.916Z] 21:43:10 INFO - --> gfx/webrender_bindings/src/bindings.rs:688:13
[task 2019-03-26T21:43:10.916Z] 21:43:10 INFO - |
[task 2019-03-26T21:43:10.916Z] 21:43:10 INFO - 688 | DeviceIntPoint::new(window_x, window_y),
[task 2019-03-26T21:43:10.916Z] 21:43:10 INFO - | ^^^^^^^^^^^^^^ use of undeclared type or module DeviceIntPoint
[task 2019-03-26T21:43:10.917Z] 21:43:10 ERROR - error[E0433]: failed to resolve: use of undeclared type or module DeviceIntSize
[task 2019-03-26T21:43:10.917Z] 21:43:10 INFO - --> gfx/webrender_bindings/src/bindings.rs:689:13
[task 2019-03-26T21:43:10.917Z] 21:43:10 INFO - |
[task 2019-03-26T21:43:10.917Z] 21:43:10 INFO - 689 | DeviceIntSize::new(window_width, window_height),
[task 2019-03-26T21:43:10.918Z] 21:43:10 INFO - | ^^^^^^^^^^^^^ use of undeclared type or module DeviceIntSize
[task 2019-03-26T21:43:10.918Z] 21:43:10 ERROR - error[E0433]: failed to resolve: use of undeclared type or module DeviceIntSize
[task 2019-03-26T21:43:10.919Z] 21:43:10 INFO - --> gfx/webrender_bindings/src/bindings.rs:691:9
[task 2019-03-26T21:43:10.919Z] 21:43:10 INFO - |
[task 2019-03-26T21:43:10.919Z] 21:43:10 INFO - 691 | DeviceIntSize::new(buffer_width, buffer_height),
[task 2019-03-26T21:43:10.919Z] 21:43:10 INFO - | ^^^^^^^^^^^^^ use of undeclared type or module DeviceIntSize
[task 2019-03-26T21:43:10.920Z] 21:43:10 ERROR - error[E0433]: failed to resolve: use of undeclared type or module FramebufferIntSize
[task 2019-03-26T21:43:10.920Z] 21:43:10 INFO - --> gfx/webrender_bindings/src/bindings.rs:733:31

Flags: needinfo?(brennie)

https://treeherder.mozilla.org/#/jobs?repo=try&revision=9c2b9e25ddc28b7685a9b6fd2c337b2f99e2eb8a

Once the fixed patch gets a re-review, it'll be good to land again.

Flags: needinfo?(brennie)

Please remove the oldest commit (D23958) from the stack - Lando also shows that one as requiring to land and it's blocking the landing. Thank you.

Flags: needinfo?(brennie)
Keywords: checkin-needed

I've marked it as closed and re-uploaded all the patches. Turns out I hit bug 1489126. I checked lando and it should be landable now.

Flags: needinfo?(brennie)
Keywords: checkin-needed

Pushed by archaeopteryx@coole-files.de:
https://hg.mozilla.org/integration/autoland/rev/f488144792c3
Optionally create PBOs with a backing buffer and store that size with the PBO r=kvark
https://hg.mozilla.org/integration/autoland/rev/5790f7047784
Capture screenshots for the Gecko profiler in WebRender r=kvark
https://hg.mozilla.org/integration/autoland/rev/6f6d9e213924
Add infrastructure for reading back screenshots for the Gecko profiler to WebRender r=kvark
https://hg.mozilla.org/integration/autoland/rev/57e16ea48eaa
Add C bindings to the Renderer::get_screenshot_async and Renderer::map_and_recycle_screenshot APIs r=kvark
https://hg.mozilla.org/integration/autoland/rev/fd545bf93564
Submit screenshots to the Gecko profiler from WebRender r=kvark,mstange
https://hg.mozilla.org/integration/autoland/rev/657499395d42
Free the Gecko profiler screenshots structures in the WebRender renderer when profiling stops r=kvark

Keywords: checkin-needed
Depends on: 1542401

After fixing this review comment I forgot to rebind the pixel pack buffer elsewhere.

Status: RESOLVED → REOPENED
Resolution: FIXED → ---

:mstange, when you get a chance, can you build this latest patch and see if it resolves bug 1542401?

Flags: needinfo?(mstange)

(In reply to Barret Rennie [:brennie] from comment #21)

:mstange, when you get a chance, can you build this latest patch and see if it resolves bug 1542401?

Tested, it works!

Flags: needinfo?(mstange)
Pushed by brennie@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/9feaaddc3761
Bind pixel pack buffer before trying to map it for readback r=gw
Status: REOPENED → RESOLVED
Closed: 5 years ago5 years ago
Resolution: --- → FIXED
Regressed by: 1551353
No longer regressed by: 1551353
Regressions: 1551353
Depends on: 1565827
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: