Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save chinmaygarde/2891df638dc6232726212bdd2820b6f8 to your computer and use it in GitHub Desktop.

Select an option

Save chinmaygarde/2891df638dc6232726212bdd2820b6f8 to your computer and use it in GitHub Desktop.
diff --git a/bin/ui/view_manager/view_impl.cc b/bin/ui/view_manager/view_impl.cc
index 7f535c66a..500c65792 100644
--- a/bin/ui/view_manager/view_impl.cc
+++ b/bin/ui/view_manager/view_impl.cc
@@ -15,6 +15,8 @@ ViewImpl::ViewImpl(ViewRegistry* registry, ViewState* state)
ViewImpl::~ViewImpl() {}
void ViewImpl::GetToken(views_v1::View::GetTokenCallback callback) {
+ FXL_LOG(INFO) << "~~~~ In function '" << __FUNCTION__ << "' of file "
+ << __FILE__ << ":" << __LINE__;
callback(state_->view_token());
}
diff --git a/bin/ui/view_manager/view_registry.cc b/bin/ui/view_manager/view_registry.cc
index 885156d4a..cd8544e2b 100644
--- a/bin/ui/view_manager/view_registry.cc
+++ b/bin/ui/view_manager/view_registry.cc
@@ -12,6 +12,7 @@
#include <lib/async/cpp/task.h>
#include <lib/async/default.h>
+#include "/Users/chinmaygarde/VersionControlled/fuchsia/garnet/public/lib/fsl/handles/object_info.h"
#include "garnet/bin/ui/view_manager/view_impl.h"
#include "garnet/bin/ui/view_manager/view_tree_impl.h"
#include "garnet/public/lib/escher/util/type_utils.h"
@@ -147,22 +148,28 @@ void ViewRegistry::CreateView(
views_v1::ViewListenerPtr view_listener,
zx::eventpair parent_export_token,
fidl::StringPtr label) {
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
FXL_DCHECK(view_request.is_valid());
FXL_DCHECK(view_owner_request.is_valid());
FXL_DCHECK(view_listener);
FXL_DCHECK(parent_export_token);
-
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
views_v1_token::ViewToken view_token;
view_token.value = next_view_token_value_++;
FXL_CHECK(view_token.value);
FXL_CHECK(!FindView(view_token.value));
-
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
// Create the state and bind the interfaces to it.
ViewState* view_state =
new ViewState(this, std::move(view_token), std::move(view_request),
std::move(view_listener), &session_, SanitizeLabel(label));
- view_state->BindOwner(std::move(view_owner_request));
+ FXL_LOG(INFO) << "~~~~ In function '" << __FUNCTION__ << "' of file "
+ << __FILE__ << ":" << __LINE__ << " Related KOID: "
+ << fsl::GetKoid(view_owner_request.channel().get());
+
+ view_state->BindOwner(std::move(view_owner_request));
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
// Export a node which represents the view's attachment point.
view_state->top_node().Export(std::move(parent_export_token));
view_state->top_node().SetTag(view_state->view_token().value);
@@ -172,7 +179,7 @@ void ViewRegistry::CreateView(
// between each view and its embedded sub-views. This is not a long-term fix.
view_state->top_node().SetTranslation(0.f, 0.f, 0.1f);
SchedulePresentSession();
-
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
// Add to registry and return token.
views_by_token_.emplace(view_state->view_token().value, view_state);
FXL_VLOG(1) << "CreateView: view=" << view_state;
@@ -180,9 +187,10 @@ void ViewRegistry::CreateView(
void ViewRegistry::OnViewDied(ViewState* view_state,
const std::string& reason) {
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
FXL_DCHECK(IsViewStateRegisteredDebug(view_state));
FXL_VLOG(1) << "OnViewDied: view=" << view_state << ", reason=" << reason;
-
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
UnregisterView(view_state);
}
@@ -210,7 +218,7 @@ void ViewRegistry::CreateViewTree(
fidl::StringPtr label) {
FXL_DCHECK(view_tree_request.is_valid());
FXL_DCHECK(view_tree_listener);
-
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
views_v1::ViewTreeToken view_tree_token;
view_tree_token.value = next_view_tree_token_value_++;
FXL_CHECK(view_tree_token.value);
@@ -220,7 +228,7 @@ void ViewRegistry::CreateViewTree(
ViewTreeState* tree_state =
new ViewTreeState(this, view_tree_token, std::move(view_tree_request),
std::move(view_tree_listener), SanitizeLabel(label));
-
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
// Add to registry.
view_trees_by_token_.emplace(tree_state->view_tree_token().value, tree_state);
FXL_VLOG(1) << "CreateViewTree: tree=" << tree_state;
@@ -230,16 +238,16 @@ void ViewRegistry::OnViewTreeDied(ViewTreeState* tree_state,
const std::string& reason) {
FXL_DCHECK(IsViewTreeStateRegisteredDebug(tree_state));
FXL_VLOG(1) << "OnViewTreeDied: tree=" << tree_state << ", reason=" << reason;
-
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
UnregisterViewTree(tree_state);
}
void ViewRegistry::UnregisterViewTree(ViewTreeState* tree_state) {
FXL_DCHECK(IsViewTreeStateRegisteredDebug(tree_state));
FXL_VLOG(1) << "UnregisterViewTree: tree=" << tree_state;
-
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
UnregisterChildren(tree_state);
-
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
// Remove from registry.
view_trees_by_token_.erase(tree_state->view_tree_token().value);
delete tree_state;
@@ -289,11 +297,15 @@ void ViewRegistry::AddChild(
uint32_t child_key,
fidl::InterfaceHandle<views_v1_token::ViewOwner> child_view_owner,
zx::eventpair host_import_token) {
+ FXL_LOG(INFO) << "~~~~ In function '" << __FUNCTION__ << "' of file "
+ << __FILE__ << ":" << __LINE__;
FXL_DCHECK(IsViewContainerStateRegisteredDebug(container_state));
FXL_DCHECK(child_view_owner);
FXL_DCHECK(host_import_token);
FXL_VLOG(1) << "AddChild: container=" << container_state
<< ", child_key=" << child_key;
+ FXL_LOG(INFO) << "~~~~ In function '" << __FUNCTION__ << "' of file "
+ << __FILE__ << ":" << __LINE__;
// Ensure there are no other children with the same key.
if (container_state->children().find(child_key) !=
@@ -302,9 +314,13 @@ void ViewRegistry::AddChild(
<< "container=" << container_state
<< ", child_key=" << child_key;
UnregisterViewContainer(container_state);
+ FXL_LOG(INFO) << "~~~~ In function '" << __FUNCTION__ << "' of file "
+ << __FILE__ << ":" << __LINE__;
return;
}
+ FXL_LOG(INFO) << "~~~~ In function '" << __FUNCTION__ << "' of file "
+ << __FILE__ << ":" << __LINE__;
// If this is a view tree, ensure it only has one root.
ViewTreeState* view_tree_state = container_state->AsViewTreeState();
if (view_tree_state && !container_state->children().empty()) {
@@ -312,8 +328,12 @@ void ViewRegistry::AddChild(
<< "container=" << container_state
<< ", child_key=" << child_key;
UnregisterViewContainer(container_state);
+ FXL_LOG(INFO) << "~~~~ In function '" << __FUNCTION__ << "' of file "
+ << __FILE__ << ":" << __LINE__;
return;
}
+ FXL_LOG(INFO) << "~~~~ In function '" << __FUNCTION__ << "' of file "
+ << __FILE__ << ":" << __LINE__;
// Add a stub, pending resolution of the view owner.
// Assuming the stub isn't removed prematurely, |OnViewResolved| will be
@@ -321,6 +341,8 @@ void ViewRegistry::AddChild(
container_state->LinkChild(child_key, std::unique_ptr<ViewStub>(new ViewStub(
this, std::move(child_view_owner),
std::move(host_import_token))));
+ FXL_LOG(INFO) << "~~~~ In function '" << __FUNCTION__ << "' of file "
+ << __FILE__ << ":" << __LINE__;
}
void ViewRegistry::RemoveChild(ViewContainerState* container_state,
@@ -426,12 +448,15 @@ void ViewRegistry::OnViewResolved(ViewStub* view_stub,
views_v1_token::ViewToken view_token,
bool success) {
FXL_DCHECK(view_stub);
-
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
ViewState* view_state = success ? FindView(view_token.value) : nullptr;
- if (view_state)
+ if (view_state) {
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
AttachResolvedViewAndNotify(view_stub, view_state);
- else
+ } else {
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
ReleaseUnavailableViewAndNotify(view_stub);
+ }
}
void ViewRegistry::TransferViewOwner(
@@ -452,16 +477,16 @@ void ViewRegistry::AttachResolvedViewAndNotify(ViewStub* view_stub,
FXL_DCHECK(view_stub);
FXL_DCHECK(IsViewStateRegisteredDebug(view_state));
FXL_VLOG(2) << "AttachViewStubAndNotify: view=" << view_state;
-
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
// Hijack the view from its current container, if needed.
HijackView(view_state);
-
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
// Attach the view's content.
if (view_stub->container()) {
view_stub->ImportHostNode(&session_);
view_stub->host_node()->AddChild(view_state->top_node());
SchedulePresentSession();
-
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
SendChildAttached(view_stub->container(), view_stub->key(),
views_v1::ViewInfo());
}
@@ -547,11 +572,15 @@ void ViewRegistry::InvalidateViewTree(ViewTreeState* tree_state,
}
void ViewRegistry::ScheduleTraversal() {
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
if (!traversal_scheduled_) {
traversal_scheduled_ = true;
async::PostTask(async_get_default(), [weak = weak_factory_.GetWeakPtr()] {
- if (weak)
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
+ if (weak) {
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
weak->Traverse();
+ }
});
}
}
@@ -560,21 +589,25 @@ void ViewRegistry::Traverse() {
FXL_DCHECK(traversal_scheduled_);
traversal_scheduled_ = false;
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
for (const auto& pair : view_trees_by_token_)
TraverseViewTree(pair.second);
}
void ViewRegistry::TraverseViewTree(ViewTreeState* tree_state) {
FXL_DCHECK(IsViewTreeStateRegisteredDebug(tree_state));
- FXL_VLOG(2) << "TraverseViewTree: tree=" << tree_state
- << ", invalidation_flags=" << tree_state->invalidation_flags();
+ FXL_LOG(INFO) << "TraverseViewTree: tree=" << tree_state
+ << ", invalidation_flags=" << tree_state->invalidation_flags();
uint32_t flags = tree_state->invalidation_flags();
if (flags & ViewTreeState::INVALIDATION_VIEWS_INVALIDATED) {
ViewStub* root_stub = tree_state->GetRoot();
- if (root_stub && root_stub->state())
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
+ if (root_stub && root_stub->state()) {
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
TraverseView(root_stub->state(), false);
+ }
}
tree_state->set_invalidation_flags(0u);
@@ -582,10 +615,11 @@ void ViewRegistry::TraverseViewTree(ViewTreeState* tree_state) {
void ViewRegistry::TraverseView(ViewState* view_state,
bool parent_properties_changed) {
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
FXL_DCHECK(IsViewStateRegisteredDebug(view_state));
- FXL_VLOG(2) << "TraverseView: view=" << view_state
- << ", parent_properties_changed=" << parent_properties_changed
- << ", invalidation_flags=" << view_state->invalidation_flags();
+ FXL_LOG(INFO) << "TraverseView: view=" << view_state
+ << ", parent_properties_changed=" << parent_properties_changed
+ << ", invalidation_flags=" << view_state->invalidation_flags();
uint32_t flags = view_state->invalidation_flags();
@@ -594,6 +628,7 @@ void ViewRegistry::TraverseView(ViewState* view_state,
if (parent_properties_changed ||
(flags & (ViewState::INVALIDATION_PROPERTIES_CHANGED |
ViewState::INVALIDATION_PARENT_CHANGED))) {
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
views_v1::ViewPropertiesPtr properties = ResolveViewProperties(view_state);
if (properties) {
if (!view_state->issued_properties() ||
@@ -621,6 +656,7 @@ void ViewRegistry::TraverseView(ViewState* view_state,
if (!(flags & ViewState::INVALIDATION_IN_PROGRESS)) {
views_v1::ViewProperties cloned_properties;
view_state->issued_properties()->Clone(&cloned_properties);
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
SendPropertiesChanged(view_state, std::move(cloned_properties));
flags = ViewState::INVALIDATION_IN_PROGRESS;
} else {
@@ -737,8 +773,8 @@ void ViewRegistry::HitTest(views_v1::ViewTreeToken view_tree_token,
session_.HitTestDeviceRay(
(float[3]){ray_origin.x, ray_origin.y, ray_origin.z},
(float[3]){ray_direction.x, ray_direction.y, ray_direction.z},
- [ this, callback = std::move(callback), ray_origin,
- ray_direction ](fidl::VectorPtr<gfx::Hit> hits) {
+ [this, callback = std::move(callback), ray_origin,
+ ray_direction](fidl::VectorPtr<gfx::Hit> hits) {
auto view_hits = fidl::VectorPtr<ViewHit>::New(0);
for (auto& hit : *hits) {
auto it = views_by_token_.find(hit.tag_value);
@@ -859,8 +895,8 @@ void ViewRegistry::SendPropertiesChanged(ViewState* view_state,
FXL_DCHECK(view_state);
FXL_DCHECK(view_state->view_listener());
- FXL_VLOG(1) << "SendPropertiesChanged: view_state=" << view_state
- << ", properties=" << properties;
+ FXL_LOG(INFO) << "SendPropertiesChanged: view_state=" << view_state
+ << ", properties=" << properties;
// It's safe to capture the view state because the ViewListener is closed
// before the view state is destroyed so we will only receive the callback
@@ -886,16 +922,17 @@ void ViewRegistry::SendChildAttached(ViewContainerState* container_state,
uint32_t child_key,
views_v1::ViewInfo child_view_info) {
FXL_DCHECK(container_state);
-
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
if (!container_state->view_container_listener())
return;
-
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
// TODO: Detect ANRs
FXL_VLOG(1) << "SendChildAttached: container_state=" << container_state
<< ", child_key=" << child_key
<< ", child_view_info=" << child_view_info;
container_state->view_container_listener()->OnChildAttached(
child_key, child_view_info, [] {});
+ FXL_LOG(INFO) << "~~~ " << __FILE__ << ":" << __LINE__;
}
void ViewRegistry::SendChildUnavailable(ViewContainerState* container_state,
diff --git a/bin/ui/view_manager/view_state.cc b/bin/ui/view_manager/view_state.cc
index e98320073..ee84fc050 100644
--- a/bin/ui/view_manager/view_state.cc
+++ b/bin/ui/view_manager/view_state.cc
@@ -46,11 +46,15 @@ void ViewState::IssueProperties(views_v1::ViewPropertiesPtr properties) {
void ViewState::BindOwner(
fidl::InterfaceRequest<views_v1_token::ViewOwner> view_owner_request) {
+ FXL_LOG(INFO) << "~~~~ In function '" << __FUNCTION__ << "' of file "
+ << __FILE__ << ":" << __LINE__;
FXL_DCHECK(!owner_binding_.is_bound());
owner_binding_.Bind(std::move(view_owner_request));
}
void ViewState::ReleaseOwner() {
+ FXL_LOG(INFO) << "~~~~ In function '" << __FUNCTION__ << "' of file "
+ << __FILE__ << ":" << __LINE__;
FXL_DCHECK(owner_binding_.is_bound());
owner_binding_.Unbind();
}
diff --git a/bin/ui/view_manager/view_stub.cc b/bin/ui/view_manager/view_stub.cc
index cc836dd8c..0ac5ab702 100644
--- a/bin/ui/view_manager/view_stub.cc
+++ b/bin/ui/view_manager/view_stub.cc
@@ -6,6 +6,7 @@
#include <utility>
+#include "/Users/chinmaygarde/VersionControlled/fuchsia/garnet/public/lib/fsl/handles/object_info.h"
#include "garnet/bin/ui/view_manager/view_registry.h"
#include "garnet/bin/ui/view_manager/view_state.h"
#include "garnet/bin/ui/view_manager/view_tree_state.h"
@@ -43,11 +44,23 @@ ViewStub::ViewStub(ViewRegistry* registry,
FXL_DCHECK(registry_);
FXL_DCHECK(owner_);
FXL_DCHECK(host_import_token_);
+ FXL_LOG(INFO) << "~~~~ In function '" << __FUNCTION__ << "' of file "
+ << __FILE__ << ":" << __LINE__;
+ owner_.set_error_handler([this] {
+ FXL_LOG(INFO) << "~~~~ In function '" << __FUNCTION__ << "' of file "
+ << __FILE__ << ":" << __LINE__;
+ OnViewResolved(views_v1_token::ViewToken(), false);
+ });
+ FXL_LOG(INFO) << "~~~~ In function '" << __FUNCTION__ << "' of file "
+ << __FILE__ << ":" << __LINE__;
- owner_.set_error_handler(
- [this] { OnViewResolved(views_v1_token::ViewToken(), false); });
+ FXL_LOG(INFO) << "~~~~ In function '" << __FUNCTION__ << "' of file "
+ << __FILE__ << ":" << __LINE__ << " Related KOID: "
+ << fsl::GetRelatedKoid(owner_.channel().get());
owner_->GetToken([this](views_v1_token::ViewToken view_token) {
+ FXL_LOG(INFO) << "~~~~ In function '" << __FUNCTION__ << "' of file "
+ << __FILE__ << ":" << __LINE__;
OnViewResolved(std::move(view_token), true);
});
}
@@ -137,6 +150,8 @@ void ViewStub::SetTreeForChildrenOfView(ViewState* view, ViewTreeState* tree) {
void ViewStub::OnViewResolved(views_v1_token::ViewToken view_token,
bool success) {
if (success && transfer_view_owner_when_view_resolved()) {
+ FXL_LOG(INFO) << "~~~~ In function '" << __FUNCTION__ << "' of file "
+ << __FILE__ << ":" << __LINE__;
// While we were waiting for GetToken(), the view was transferred to a new
// ViewOwner). Now that we got the GetToken() call, transfer the ownership
// correctly internally.
@@ -164,6 +179,8 @@ void ViewStub::OnViewResolved(views_v1_token::ViewToken view_token,
// 2. Or, the ViewOwner was closed before the GetToken() callback (in
// which case view_token is null).
owner_.Unbind();
+
+ FXL_LOG(INFO) << "~~~~~~ " << __FILE__ << ":" << __LINE__;
registry_->OnViewResolved(this, std::move(view_token), success);
}
}
diff --git a/public/lib/fidl/cpp/internal/logging.cc b/public/lib/fidl/cpp/internal/logging.cc
index 0144027e3..34c096ed9 100644
--- a/public/lib/fidl/cpp/internal/logging.cc
+++ b/public/lib/fidl/cpp/internal/logging.cc
@@ -7,6 +7,7 @@
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
+#include <zircon/crashlogger.h>
namespace fidl {
namespace internal {
@@ -24,6 +25,7 @@ void ReportEncodingError(const Message& message,
"type %.*s, %" PRIu32 " bytes, %" PRIu32 " handles\n",
file, line, error_msg, static_cast<int>(type_name_length), type_name,
message.bytes().actual(), message.handles().actual());
+ crashlogger_request_backtrace();
}
void ReportDecodingError(const Message& message,
@@ -39,6 +41,7 @@ void ReportDecodingError(const Message& message,
"type %.*s, %" PRIu32 " bytes, %" PRIu32 " handles\n",
file, line, error_msg, static_cast<int>(type_name_length), type_name,
message.bytes().actual(), message.handles().actual());
+ crashlogger_request_backtrace();
}
void ReportChannelWritingError(const Message& message,
@@ -54,6 +57,7 @@ void ReportChannelWritingError(const Message& message,
"type %.*s, %" PRIu32 " bytes, %" PRIu32 " handles\n",
file, line, status, static_cast<int>(type_name_length), type_name,
message.bytes().actual(), message.handles().actual());
+ crashlogger_request_backtrace();
}
} // namespace internal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment