Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[Impeller] GPU Tracer for GLES. #47080

Merged
merged 10 commits into from
Oct 20, 2023
Merged

Conversation

jonahwilliams
Copy link
Member

@jonahwilliams jonahwilliams commented Oct 18, 2023

Trace GPU execution time on GLES using GL_EXT_disjoint_timer_query. This requires a per-app opt in from the Android Manifest with the key "io.flutter.embedding.android.EnableOpenGLGPUTracing set to true.

@jonahwilliams jonahwilliams marked this pull request as ready for review October 19, 2023 17:31
@chinmaygarde chinmaygarde self-requested a review October 19, 2023 20:17
@chinmaygarde chinmaygarde changed the title [Impeller] GPU Tracer for GLES [Impeller] GPU Tracer for GLES. Oct 19, 2023
has_started_frame_ = true;

FML_DCHECK(!active_frame_.has_value());
FML_DCHECK(query != 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is redundant with the query == 0 check above

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

std::deque<uint32_t> pending_traces_;
std::optional<uint32_t> active_frame_ = std::nullopt;
std::thread::id raster_thread_;
bool has_started_frame_ = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has_started_frame_ can be removed. The code can instead check whether active_frame_ contains a value.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

// For reasons unknown to me, querying the state of more than
// on query object per frame causes crashes on a Pixel 6 pro.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: "on" -> "one"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

// For reasons unknown to me, querying the state of more than
// on query object per frame causes crashes on a Pixel 6 pro.
// It does not crash on an S10.
auto latest_query = pending_traces_.front();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think latest_query implies that this is the most recent query, when it's actually the least recent.

I'd rename this to query

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


// For reasons unknown to me, querying the state of more than
// on query object per frame causes crashes on a Pixel 6 pro.
// It does not crash on an S10.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where exactly is the crash happening?

If the tracer can only consume one pending query per MarkFrameStart call, then that means the pending traces queue will grow unbounded each time a query result is unavailable at the next MarkFrameStart.

@jonahwilliams
Copy link
Member Author

This actually works OK on the Pixel 7s we have in the device lab. On a Pixel 6 pro the crash is almost immediate and appears to be in the driver:

signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0000000000000000
Cause: null pointer dereference
    x0  b40000797364acd0  x1  0000000000000000  x2  0000000000000000  x3  0000007999a60d98
    x4  0000000000000003  x5  0000000007ee634c  x6  71647164636d6471  x7  7f7f7f7f7f7f7f7f
    x8  0000000000000000  x9  0000000000000004  x10 0000000000000001  x11 0000000000000000
    x12 0000000000000008  x13 b400007b275cd128  x14 0000000000000007  x15 0000000000000028
    x16 0000000000000007  x17 0000000000000007  x18 000000798b636000  x19 b40000797364acd0
    x20 0000000000000000  x21 b4000079736b07b0  x22 b4000079735b4660  x23 b40000797360fef0
    x24 0000007999a65000  x25 000000799b889e6e  x26 0000007999a60d90  x27 0000000000008866
    x28 0000007999a60d98  x29 0000000000000001
    lr  00000079ece308a0  sp  0000007999a60a20  pc  00000079ece308ac  pst 0000000060001000
backtrace:
      #00 pc 000000000082d8ac  /vendor/lib64/egl/libGLES_mali.so (gles_fb_flush_compute_nx+92) (BuildId: 045075399765d011)
      #01 pc 00000000007e30ac  /vendor/lib64/egl/libGLES_mali.so (gles2_queryp_flush+108) (BuildId: 045075399765d011)
      #02 pc 00000000007e4050  /vendor/lib64/egl/libGLES_mali.so (gles_queryp_object_flush_for_result+64) (BuildId: 045075399765d011)
      #03 pc 00000000007e2760  /vendor/lib64/egl/libGLES_mali.so (gles2_queryp_get_query_object_getv+464) (BuildId: 045075399765d011)
      #04 pc 0000000002074c44  /data/app/~~KIK6odR8TVi-SXQaZ2msSQ==/com.gskinner.flutter.wonders-RurBsIIIDsouyhOiGFYG-Q==/base.apk!libflutter.so (offset 0xff23000) (auto impeller::GLProc<void (unsigned int, unsigned int, int*)>::operator()<unsigned int&, int, int*>(unsigned int&, int&&, int*&&) const+152) (BuildId: 46301208b8388191c9b7feb94f655a031d7f1eb7)
      #05 pc 000000000207803c  /data/app/~~KIK6odR8TVi-SXQaZ2msSQ==/com.gskinner.flutter.wonders-RurBsIIIDsouyhOiGFYG-Q==/ba

Based on some other reports, this seems like a fiddly API (https://bugs.chromium.org/p/chromium/issues/detail?id=453965) . I'm going to make usage opt in so we can use it on our benchmarks when necessary without worrying about broader device compatibility.

return;
}

FML_DCHECK(!active_frame_.has_value());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This duplicates the active_frame_.has_value() check above

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


void GPUTracerGLES::MarkFrameEnd(const ProcTableGLES& gl) {
if (!enabled_ || std::this_thread::get_id() != raster_thread_ ||
!active_frame_.has_value() || !active_frame_.has_value()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the second copy of !active_frame_.has_value()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 20, 2023
@auto-submit auto-submit bot merged commit 29168dd into flutter:main Oct 20, 2023
@jonahwilliams jonahwilliams deleted the gles_tracer branch October 20, 2023 17:52
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 20, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Oct 20, 2023
…136982)

flutter/engine@d46933e...b27e1b3

2023-10-20 47866232+chunhtai@users.noreply.github.com Add link support in web accessibility (flutter/engine#46117)
2023-10-20 mdebbar@google.com [web] Support `flutterViewId` in platform view messages (flutter/engine#46891)
2023-10-20 jacksongardner@google.com Fix async image loading issues in skwasm. (flutter/engine#47117)
2023-10-20 flar@google.com Add option to save Impeller failure images in rendertests (flutter/engine#47142)
2023-10-20 skia-flutter-autoroll@skia.org Roll Skia from b960e9140f56 to 9ffd5ef9a9ed (3 revisions) (flutter/engine#47167)
2023-10-20 chris@bracken.jp [macOS] Eliminate extraneous loadView calls (flutter/engine#47166)
2023-10-20 skia-flutter-autoroll@skia.org Roll Dart SDK from ba96a157a8eb to 53fee35b299f (1 revision) (flutter/engine#47165)
2023-10-20 jonahwilliams@google.com [Impeller] GPU Tracer for GLES. (flutter/engine#47080)
2023-10-20 skia-flutter-autoroll@skia.org Roll Skia from de628929015d to b960e9140f56 (2 revisions) (flutter/engine#47164)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC jimgraham@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
harryterkelsen pushed a commit that referenced this pull request Oct 23, 2023
Trace GPU execution time on GLES using GL_EXT_disjoint_timer_query. This requires a per-app opt in from the Android Manifest with the key `"io.flutter.embedding.android.EnableOpenGLGPUTracing` set to true.
bdero added a commit to bdero/impeller-cmake that referenced this pull request Nov 1, 2023
bdero added a commit to bdero/impeller-cmake that referenced this pull request Nov 1, 2023
bdero added a commit to bdero/impeller-cmake that referenced this pull request Nov 1, 2023
bdero added a commit that referenced this pull request Nov 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App e: impeller platform-android
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants