Skip to content

Commit db0f009

Browse files
authored
added view hierarchy docs (#11331)
1 parent 61b348d commit db0f009

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed
64.6 KB
Loading
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
title: "View Hierarchy"
3+
description: "Learn more about debugging the view hierarchy when an error occurs. Sentry pairs the view hierarchy representation with the original event, giving you additional insight into issues."
4+
---
5+
6+
Sentry makes it possible to render a JSON representation of the scene of an error and includes it as an <PlatformLink to="/enriching-events/attachments/">attachment</PlatformLink>.
7+
8+
This feature only applies to SDKs with a user interface, such as the ones for mobile and desktop applications. Capturing the scene and creating the view hierarchy requires the UI thread and in the event of a crash, that might not be available. Another example where the view hierarchy might not be available is when the event happens before the screen starts to load. So inherently, this feature is a best effort solution.
9+
10+
## Enabling View Hierarchy Attachments
11+
12+
View hierarchy debugging is an opt-in feature. You can enable it via the configuration editor `Enrichment -> Attach Hierarchy` or programmatically:
13+
14+
```csharp
15+
options.AttachViewHierarchy = true;
16+
```
17+
18+
### Customize View Hierarchy Capturing
19+
20+
Because capturing view hierarchy can be a resource-intensive operation as the SDK traverses the scene at the time of an error, there are several controls available to you.
21+
22+
<ConfigKey name="MaxViewHierarchyRootObjects">
23+
24+
Allows you to limit the amount of gameobjects to be traversed and included in the view hierarchy.
25+
26+
</ConfigKey>
27+
28+
<ConfigKey name="MaxViewHierarchyDepth">
29+
30+
Allows you to limit the maximum depth of child-gameobject the SDK will attempt to traverse to include in the view hierarchy.
31+
32+
</ConfigKey>
33+
34+
<ConfigKey name="MaxViewHierarchyObjectChildCount">
35+
36+
Allows you to limit the maximum count of child-gameobjects per individual gameobject the SDK will attempt to include in the view hierarchy.
37+
38+
</ConfigKey>
39+
40+
These are also available for programmatic configuration on the options object:
41+
42+
```csharp
43+
options.MaxViewHierarchyDepth = 10;
44+
options.MaxViewHierarchyRootObjects = 100;
45+
options.MaxViewHierarchyObjectChildCount = 20;
46+
```
47+
48+
## Viewing View Hierarchy Attachments
49+
50+
View hierarchies appear in the "Attachments" tab, where you can view all attachments, as well as associated events. Click the event ID to open the [Issue Details](/product/issues/issue-details) page of that specific event.
51+
52+
<Include name="common-imgs/viewhierarchy-list-example" />
53+
54+
On the **Issue Details** page, you can interact with the view hierarchy attachment in a section called "View Hierarchy". This section represents the state of your scene at the time of an error event. There are two displays: a tree view, and detailed view for a selected node. You can select nodes in the tree to view the properties collected by the SDK. The SDK will report on the following keys for each node in the view:
55+
56+
- `Tag` The gameobject's tag
57+
- `Position` The gameobject's position
58+
- `Rotation` The gameobject's rotation in euler angles
59+
- `Scale` The gameobject's scale
60+
- `Active` Whether the gameobject was active
61+
- `Extra` A list of names of all the attached MonoBehaviours on that gameobject
62+
63+
This feature can be used as an exploratory tool to debug reference issues, or gain a better understanding of the relationship between gameobjects.
64+
65+
![View Hierarchy Example](./img/viewhierarchy-example-unity.png)

0 commit comments

Comments
 (0)