[M120 Migration] Add check and logs to avoid crash 38/317438/4
authorfr.fang <fr.fang@samsung.com>
Mon, 9 Sep 2024 16:51:47 +0000 (00:51 +0800)
committerfengrong fang <fr.fang@samsung.com>
Thu, 12 Sep 2024 06:32:45 +0000 (06:32 +0000)
1.Add check in EWebAccessibilityObject::GetBrowserAccessibilityManager
to avoid crash.
2.Add some log to trace accessibility issues

Refer:
https://review.tizen.org/gerrit/#/c/305192/

Change-Id: I20e900f13fb49875aa88d6967cf46bb380905bca
Signed-off-by: fr.fang <fr.fang@samsung.com>
content/browser/accessibility/browser_accessibility_state_impl.cc
tizen_src/ewk/efl_integration/eweb_accessibility.cc
tizen_src/ewk/efl_integration/eweb_accessibility_object.cc
tizen_src/ewk/efl_integration/eweb_accessibility_util.cc
tizen_src/ewk/efl_integration/web_contents_observer_efl.cc

index 0705a06bdfb4fba4174ba13c80797611ba4db525..7e482d9958d62f88700cd9f998c714c6c9bdbea1 100644 (file)
@@ -195,6 +195,7 @@ void BrowserAccessibilityStateImpl::OnScreenReaderStopped() {
 void BrowserAccessibilityStateImpl::EnableAccessibility() {
   // First disable any non-additive modes that restrict or filter the
   // information available in the tree.
+  LOG(INFO) << __func__;
   RemoveAccessibilityModeFlags(ui::kAXModeFormControls);
 
   AddAccessibilityModeFlags(ui::kAXModeComplete);
index 0563433efc085813c28a749ceeab7201b7124601..cf3f43aec030909f3e2861730d634cf3c7313160 100644 (file)
@@ -18,9 +18,13 @@ EWebAccessibility::EWebAccessibility(Evas_Object* root_object,
                                      std::unique_ptr<Observer> observer)
     : root_object_(root_object),
       web_contents_(web_contents),
-      observer_(std::move(observer)) {}
+      observer_(std::move(observer)) {
+  LOG(INFO) << __func__;
+}
 
-EWebAccessibility::~EWebAccessibility() {}
+EWebAccessibility::~EWebAccessibility() {
+  LOG(INFO) << __func__;
+}
 
 /* LCOV_EXCL_START */
 AtkObject* EWebAccessibility::GetRootObject() {
@@ -47,14 +51,25 @@ void EWebAccessibility::OnFocusOut() {
 void EWebAccessibility::AddPlug() {
   if (!(IsMobileProfile() || IsTvProfile()))
     return;
+  LOG(INFO) << __func__ << " start";
 
   if (!accessibility_object_)
     accessibility_object_.reset(new EWebAccessibilityObject(web_contents_));
 
   auto plug_id =
       atk_plug_get_id(ATK_PLUG(accessibility_object_->GetEflAtkObject()));
+
+  if (root_object_)
+    LOG(INFO) << "root_object_: " << root_object_;
+  else {
+    LOG(ERROR) << "root_object_ is nullptr.";
+    return;
+  }
+
   if (plug_id) {
     auto data = evas_object_data_get(root_object_, kPlugIdKey);
+    LOG(INFO) << "evas_object_data_get data: " << data
+              << " plug_id: " << plug_id;
     if (data && !strcmp((char*)plug_id, (char*)data))
       return;
 
@@ -65,25 +80,37 @@ void EWebAccessibility::AddPlug() {
     atk_bridge_adaptor_cleanup();
     LOG(ERROR) << "atk_plug_get_id failed.";
   }
+  LOG(INFO) << __func__ << " end";
 }
 /* LCOV_EXCL_STOP */
 
 void EWebAccessibility::RemovePlug() {
   if (!(IsMobileProfile() || IsTvProfile()))
     return;
+  LOG(INFO) << __func__ << " start";
+
+  if (root_object_)
+    LOG(INFO) << "root_object_: " << root_object_;
+  else {
+    LOG(WARNING) << "root_object_ is nullptr.";
+    return;
+  }
 
   auto plug_id =
       static_cast<char*>(evas_object_data_get(root_object_, kPlugIdKey));
   if (plug_id) {
     /* LCOV_EXCL_START */
     evas_object_data_set(root_object_, kPlugIdKey, nullptr);
+    LOG(INFO) << " free plug_id " << plug_id;
     free(plug_id);
   }
   /* LCOV_EXCL_STOP */
   accessibility_object_.reset();
+  LOG(INFO) << __func__ << " end";
 }
 
 void EWebAccessibility::NotifyAccessibilityStatus(bool is_enabled) {
+  LOG(INFO) << __func__ << " start is_enabled : " << is_enabled;
   if (IsMobileProfile() || IsTvProfile())
     (is_enabled) ? AddPlug() : RemovePlug();
 
@@ -97,4 +124,5 @@ void EWebAccessibility::NotifyAccessibilityStatus(bool is_enabled) {
     observer_->OnAccessibilityStatusChanged(is_enabled);
   }
 #endif
+  LOG(INFO) << __func__ << " end";
 }
index fd2bd39d2db61a971901f8f1f318f06704422beb..414818275b1d8c765d2d652e4175574c029b8525 100644 (file)
@@ -168,6 +168,7 @@ EWebAccessibilityObject::EWebAccessibilityObject(
     : web_contents_(web_contents),
       efl_main_layout_(static_cast<content::WebContentsImplEfl*>(web_contents_)
                            ->GetEflMainLayout()) {
+  LOG(INFO) << __func__;
   evas_object_event_callback_add(efl_main_layout_, EVAS_CALLBACK_SHOW,
                                  NativeViewShowCallback, this);
   evas_object_event_callback_add(efl_main_layout_, EVAS_CALLBACK_HIDE,
@@ -193,6 +194,7 @@ EWebAccessibilityObject::EWebAccessibilityObject(
 }
 
 EWebAccessibilityObject::~EWebAccessibilityObject() {
+  LOG(INFO) << __func__;
   evas_object_event_callback_del(efl_main_layout_, EVAS_CALLBACK_SHOW,
                                  NativeViewShowCallback);
   evas_object_event_callback_del(efl_main_layout_, EVAS_CALLBACK_HIDE,
@@ -205,6 +207,7 @@ void EWebAccessibilityObject::NativeViewShowCallback(void* data,
                                                      Evas*,
                                                      Evas_Object*,
                                                      void*) {
+  LOG(INFO) << __func__;
   auto thiz = static_cast<EWebAccessibilityObject*>(data);
   atk_object_notify_state_change(ATK_OBJECT(thiz->GetEflAtkObject()),
                                  ATK_STATE_SHOWING, TRUE);
@@ -215,6 +218,7 @@ void EWebAccessibilityObject::NativeViewHideCallback(void* data,
                                                      Evas*,
                                                      Evas_Object*,
                                                      void*) {
+  LOG(INFO) << __func__;
   auto thiz = static_cast<EWebAccessibilityObject*>(data);
   atk_object_notify_state_change(ATK_OBJECT(thiz->GetEflAtkObject()),
                                  ATK_STATE_SHOWING, FALSE);
@@ -222,6 +226,11 @@ void EWebAccessibilityObject::NativeViewHideCallback(void* data,
 
 content::BrowserAccessibilityManager*
 EWebAccessibilityObject::GetBrowserAccessibilityManager() const {
+  if (!web_contents_) {
+    LOG(ERROR) << "web_contents_ is null";
+    return nullptr;
+  }
+
   auto frame = static_cast<content::RenderFrameHostImpl*>(
       web_contents_->GetPrimaryMainFrame());
   if (!frame) {
index 5d37d466a6e98e2635e0d44dc5968fd78008d509..5ee507952b1d4f3f4abf20e4e9855082c73c9e20 100644 (file)
@@ -199,6 +199,7 @@ EWebAccessibilityUtil::EWebAccessibilityUtil()
 {
   if (getuid() == 0)
     return;
+  LOG(INFO) << __func__;
 
   AtkUtilClass* atkUtilClass = ATK_UTIL_CLASS(g_type_class_ref(ATK_TYPE_UTIL));
   atkUtilClass->get_toolkit_name = eweb_util_get_toolkit_name;
@@ -211,6 +212,7 @@ EWebAccessibilityUtil::EWebAccessibilityUtil()
 }
 
 EWebAccessibilityUtil::~EWebAccessibilityUtil() {
+  LOG(INFO) << __func__;
   vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS,
                            PropertyChangedCb);
   if (!IsTvProfile())
@@ -365,6 +367,7 @@ void EWebAccessibilityUtil::Deactivate(bool deactivated) {
     return;
   }
 
+  LOG(INFO) << __func__;
   ToggleBrowserAccessibility(result, std::nullopt);
 }
 #endif
@@ -386,7 +389,7 @@ void EWebAccessibilityUtil::ToggleAtk(bool& atk_status) {
     return;
     /* LCOV_EXCL_STOP */
   }
-
+  LOG(INFO) << __func__;
   ToggleBrowserAccessibility(result, std::nullopt);
 }
 
index 676bdd0e4bd14da87f422f5cafc13a1c10677e57..6e7c2324a816e5d120e1237485ef077785b1ffae 100644 (file)
@@ -105,8 +105,10 @@ void WebContentsObserverEfl::DidStartNavigation(
   if (!navigation_handle->IsInMainFrame())
     return;
 #if defined(TIZEN_ATK_SUPPORT)
-  if (web_view_->CheckLazyInitializeAtk())
+  if (web_view_->CheckLazyInitializeAtk()) {
     web_view_->InitAtk();
+    LOG(INFO) << "InitAtk successfully.";
+  }
 #endif
   web_view_->SmartCallback<EWebViewCallbacks::ProvisionalLoadStarted>().call();
 }