Skip to content

Commit 674b5de

Browse files
schwa423CQ Bot
authored andcommitted
[scenic] ViewTree tracing/cleanup
Add trace macros. Remove unnecessary includes, and readd them wherever they were transitively required. Bug: 401298250 Change-Id: I410af89838e9e7f4766b301803257ffa57502387 Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1231586 Fuchsia-Auto-Submit: Josh Gargus <[email protected]> Reviewed-by: Justin Kobler <[email protected]> Commit-Queue: Auto-Submit <[email protected]>
1 parent e2e31c0 commit 674b5de

File tree

8 files changed

+26
-9
lines changed

8 files changed

+26
-9
lines changed

src/ui/scenic/lib/flatland/link_system.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <lib/trace/event.h>
99

1010
#include "src/ui/scenic/lib/utils/dispatcher_holder.h"
11+
#include "src/ui/scenic/lib/utils/helpers.h"
1112
#include "src/ui/scenic/lib/utils/task_utils.h"
1213

1314
#include <glm/gtc/matrix_access.hpp>

src/ui/scenic/lib/input/touch_source_base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#ifndef SRC_UI_SCENIC_LIB_INPUT_TOUCH_SOURCE_BASE_H_
66
#define SRC_UI_SCENIC_LIB_INPUT_TOUCH_SOURCE_BASE_H_
77

8+
#include <fuchsia/ui/pointer/cpp/fidl.h>
89
#include <lib/fit/function.h>
910
#include <lib/inspect/cpp/inspect.h>
1011
#include <zircon/status.h>

src/ui/scenic/lib/screenshot/tests/flatland_screenshot_unittest.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "src/ui/scenic/lib/screen_capture/screen_capture_buffer_collection_importer.h"
2525
#include "src/ui/scenic/lib/screenshot/screenshot_manager.h"
2626
#include "src/ui/scenic/lib/screenshot/tests/mock_image_compression.h"
27+
#include "src/ui/scenic/lib/utils/helpers.h"
2728

2829
using allocation::BufferCollectionImporter;
2930
using fuchsia::ui::compression::internal::ImageCompressorEncodePngRequest;

src/ui/scenic/lib/view_tree/snapshot_types.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include <lib/syslog/cpp/macros.h>
88

9-
#include "src/ui/scenic/lib/utils/math.h"
9+
#include "src/ui/scenic/lib/utils/helpers.h"
1010

1111
namespace {
1212

@@ -84,8 +84,8 @@ bool Snapshot::IsDescendant(zx_koid_t descendant_koid, zx_koid_t ancestor_koid)
8484
}
8585

8686
std::vector<zx_koid_t> Snapshot::GetAncestorsOf(zx_koid_t koid) const {
87-
// TODO(https://fxbug.dev/42050703): Turn this back into a DCHECK once we solve the ViewTree-flakiness
88-
// issue.
87+
// TODO(https://fxbug.dev/42050703): Turn this back into a DCHECK once we solve the
88+
// ViewTree-flakiness issue.
8989
if (view_tree.count(koid) == 0) {
9090
FX_LOGS(ERROR) << "Tried to GetAncestorsOf() a koid not in the ViewTree";
9191
return {};

src/ui/scenic/lib/view_tree/snapshot_types.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#ifndef SRC_UI_SCENIC_LIB_VIEW_TREE_SNAPSHOT_TYPES_H_
66
#define SRC_UI_SCENIC_LIB_VIEW_TREE_SNAPSHOT_TYPES_H_
77

8+
// TODO(https://fxbug.dev/404958102): delete mentions of GFX in `ViewNode`, then delete this.
9+
#include <fuchsia/math/cpp/fidl.h>
810
#include <fuchsia/ui/views/cpp/fidl.h>
911
#include <lib/fit/function.h>
1012
#include <zircon/types.h>
@@ -16,8 +18,6 @@
1618
#include <unordered_set>
1719
#include <vector>
1820

19-
#include "src/ui/scenic/lib/utils/helpers.h"
20-
2121
#include <glm/glm.hpp>
2222

2323
namespace view_tree {
@@ -59,14 +59,17 @@ struct ViewNode {
5959

6060
// Set to true when a GFX view has generated the |is_rendering| signal. For flatland views, this
6161
// field is set to |std::nullopt|.
62+
// TODO(https://fxbug.dev/404958102): delete mentions of GFX.
6263
std::optional<bool> gfx_is_rendering;
6364

6465
// The conversion ratio from physical pixels (of a display) to logical pixels (of the coordinate
6566
// system of the view). For flatland views, this field is set to |std::nullopt|.
67+
// TODO(https://fxbug.dev/404958102): delete mentions of GFX.
6668
std::optional<std::array<float, 2>> gfx_pixel_scale;
6769

6870
// The offset data for the view's bounding box, in the coordinate system of that view. For
6971
// flatland views, this field is set to |std::nullopt|.
72+
// TODO(https://fxbug.dev/404958102): delete mentions of GFX.
7073
std::optional<fuchsia::math::InsetF> gfx_inset;
7174

7275
bool operator==(const ViewNode& other) const;

src/ui/scenic/lib/view_tree/tests/geometry_provider_unittest.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "src/ui/scenic/lib/view_tree/geometry_provider.h"
66

7+
#include <fuchsia/ui/composition/cpp/fidl.h>
78
#include <fuchsia/ui/views/cpp/fidl.h>
89
#include <lib/syslog/cpp/macros.h>
910
#include <lib/zx/time.h>

src/ui/scenic/lib/view_tree/view_tree_snapshotter.cc

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ void TreeWalk(const std::unordered_map<zx_koid_t, ViewNode>& view_tree, zx_koid_
4040
}
4141

4242
bool ValidateSnapshot(const Snapshot& snapshot) {
43+
TRACE_DURATION("gfx", "ViewTreeSnapshotter::ValidateSnapshot");
44+
4345
const auto& [root, view_tree, unconnected_views, hit_testers] = snapshot;
4446
if (view_tree.empty() && root == ZX_KOID_INVALID) {
4547
return true;
@@ -70,6 +72,8 @@ bool ValidateSnapshot(const Snapshot& snapshot) {
7072
}
7173

7274
bool ValidateSubtree(const SubtreeSnapshot& subtree) {
75+
TRACE_DURATION("gfx", "ViewTreeSnapshotter::ValidateSubtree");
76+
7377
const auto& [root, view_tree, unconnected_views, hit_tester, tree_boundaries] = subtree;
7478
if (view_tree.empty() && root == ZX_KOID_INVALID) {
7579
return true;
@@ -115,8 +119,8 @@ ViewTreeSnapshotter::ViewTreeSnapshotter(std::vector<SubtreeSnapshotGenerator> s
115119
: subtree_generators_(std::move(subtree_generators)) {
116120
for (auto& [subscriber_callback, dispatcher] : subscribers) {
117121
FX_DCHECK(dispatcher);
118-
// TODO(https://fxbug.dev/42155704): We save the callback directly and ignore the dispatcher as a
119-
// workaround to avoid flakes. Rework this after deciding on a new synchronization mechanism.
122+
// TODO(https://fxbug.dev/42155704): We save the callback directly and ignore the dispatcher as
123+
// a workaround to avoid flakes. Rework this after deciding on a new synchronization mechanism.
120124
subscriber_callbacks_.emplace_back(std::move(subscriber_callback));
121125
}
122126
}
@@ -129,10 +133,16 @@ void ViewTreeSnapshotter::UpdateSnapshot() const {
129133

130134
// Merge subtrees.
131135
for (auto& generate_subtrees : subtree_generators_) {
132-
auto subtree = generate_subtrees();
136+
SubtreeSnapshot subtree;
137+
{
138+
TRACE_DURATION("gfx", "ViewTreeSnapshotter::UpdateSnapshot [generate]");
139+
subtree = generate_subtrees();
140+
}
133141
FX_DCHECK(ValidateSubtree(subtree));
134142
auto& [root, view_tree, unconnected_views, hit_tester, subtree_boundaries] = subtree;
135143

144+
TRACE_DURATION("gfx", "ViewTreeSnapshotter::UpdateSnapshot [merge]");
145+
136146
if (new_snapshot->root == ZX_KOID_INVALID) {
137147
new_snapshot->root = root;
138148
}
@@ -177,6 +187,7 @@ void ViewTreeSnapshotter::UpdateSnapshot() const {
177187

178188
// Update all subscribers with the new snapshot.
179189
for (const auto& subscriber_callback : subscriber_callbacks_) {
190+
TRACE_DURATION("gfx", "ViewTreeSnapshotter::UpdateSnapshot [subscriber]");
180191
subscriber_callback(new_snapshot);
181192
}
182193
}

src/ui/scenic/lib/view_tree/view_tree_snapshotter.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include <vector>
1111

12-
#include "src/ui/scenic/lib/scheduling/frame_scheduler.h"
1312
#include "src/ui/scenic/lib/view_tree/snapshot_types.h"
1413

1514
namespace view_tree {

0 commit comments

Comments
 (0)