[M34-Merge] Make sure RenderWidgetHostViewEfl is fully initialized after Init call
authorPiotr Szawdyński <p.szawdynski@samsung.com>
Fri, 9 Jan 2015 10:45:04 +0000 (11:45 +0100)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
Currently the RenderWidgetHostViewEfl::Init_EvasGL may not be called
during object initialization. This can take place when the content_image_
for the view has empty size. It often happens in cases where the widget
was created but not yet inserted into the layout tree of the application.
The direct result of such approach is that any code that needs to access
Evas_GL* properties of RWHVEFL needs to make sure the properties are actually
valid. One example of such code is EWebView::GetSnapshot function. Currently
it does not contain the necessary checks leading to seemingly random crashes
when switching tabs in EFL browser.

Instead of lazy initializing Evas_GL we can simply ensure that the initial
size of the widget is always specified. Besides simplifying RWHVEFL
initialization it'll also help us avoid potential future problems with invalid
Evas_GL objects. It'll also make sure that the application can always take a
snapshot of the current content.

The patch uses the official way of specifying initial content size offered by
content API (WebContents::CreateParams::initial_size).

To avoid code duplication the WebContents related initialization code is moved
into a common function EWebView::InitializeContent.

Original patch:
"Make sure RenderWidgetHostViewEfl is fully initailzied after Init call"
by Piotr Tworek, http://165.213.202.130:8080/#/c/69477/

Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=10194
Reviewed by: Janusz Majnert, Piotr Tworek, SeungSeop Park

Change-Id: I1c2c9f53ac55e84ad7890fa74907de2d164193d7
Signed-off-by: Piotr Szawdyński <p.szawdynski@samsung.com>
tizen_src/impl/browser/renderer_host/render_widget_host_view_efl.cc
tizen_src/impl/browser/renderer_host/render_widget_host_view_efl.h [changed mode: 0755->0644]
tizen_src/impl/browser/web_contents/web_contents_view_efl.cc
tizen_src/impl/eweb_view.cc
tizen_src/impl/eweb_view.h

index b8b46fb..d589444 100644 (file)
@@ -146,7 +146,7 @@ RenderWidgetHostViewEfl::RenderWidgetHostViewEfl(RenderWidgetHost* widget, EWebV
   gesture_recognizer_->AddGestureEventHelper(this);
 }
 
-void RenderWidgetHostViewEfl::Init(Evas_Object* view) {
+void RenderWidgetHostViewEfl::Init(Evas_Object* view, const gfx::Size& size) {
   DCHECK(view);
   content_image_ = view;
   evas_ = evas_object_evas_get(view);
@@ -156,14 +156,8 @@ void RenderWidgetHostViewEfl::Init(Evas_Object* view) {
   im_context_ = IMContextEfl::Create(this);
 
   if (is_hw_accelerated_) {
-    gfx::Rect bounds = GetViewBoundsInPix();
-    if (!bounds.IsEmpty()) {
-      Init_EvasGL(bounds.width(), bounds.height());
-    } else {
-      int w, h;
-      evas_object_image_size_get(content_image_, &w, &h);
-      Init_EvasGL(w, h);
-    }
+    DCHECK(!size.IsEmpty());
+    Init_EvasGL(size.width(), size.height());
   }
 
 #if defined(OS_TIZEN_MOBILE)
old mode 100755 (executable)
new mode 100644 (file)
index 6bf74f6..28b9ea1
@@ -187,7 +187,7 @@ class RenderWidgetHostViewEfl
   void set_magnifier(bool status);
 
   void Init_EvasGL(int width, int height);
-  void Init(Evas_Object* view);
+  void Init(Evas_Object* view, const gfx::Size& size);
 
   void set_eweb_view(EWebView* webview) { web_view_ = webview; }
   EWebView* eweb_view() const { return web_view_; }
@@ -233,7 +233,7 @@ class RenderWidgetHostViewEfl
 
   void SetComposition(const ui::CompositionText& composition_text);
   void ConfirmComposition(base::string16& text);
-  
+
   bool IsScrollOffsetChanged() const { return scroll_offset_changed_; }
   void SetScrollOffsetChanged() { scroll_offset_changed_ = true; }
 
index e904e37..03c330d 100644 (file)
@@ -50,7 +50,7 @@ void WebContentsViewEfl::CreateView(const gfx::Size& initial_size,
 RenderWidgetHostViewBase* WebContentsViewEfl::CreateViewForWidget(
     RenderWidgetHost* render_widget_host, bool is_guest_view_hack) {
   RenderWidgetHostViewEfl* view = new RenderWidgetHostViewEfl(render_widget_host, GetEWebView());
-  view->Init(native_view_);
+  view->Init(native_view_, requested_size_);
   view->Show();
 
   if (view_mode_ != tizen_webview::TW_VIEW_MODE_WINDOWED) {
index ae0ea64..49f4f79 100644 (file)
@@ -269,9 +269,7 @@ void EWebView::Initialize() {
     // the result of the callback is the first one that has been created.
     contents_for_new_window_ = NULL;
   } else {
-    WebContents::CreateParams params(context_->browser_context());
-    params.context = GetContentImageObject();
-    web_contents_.reset(WebContents::Create(params));
+    InitializeContent();
   }
   web_contents_delegate_.reset(new WebContentsDelegateEfl(this));
   web_contents_->SetDelegate(web_contents_delegate_.get());
@@ -1916,18 +1914,37 @@ bool EWebView::StopInspectorServer() {
 }
 
 void EWebView::HandleRendererProcessCrash() {
-  const char* last_url = GetURL();
+  InitializeContent();
+}
+
+void EWebView::InitializeContent() {
+  int width, height;
+  evas_object_geometry_get(evas_object_, 0, 0, &width, &height);
+
+  if (width == 0 || height == 0) {
+    // The evas_object_ may not be part of the EFL/Elementary layout tree.
+    // As a result we may not know it's size, yet. In such case use window
+    // size instead. RenderWidgetHostViewEfl can already handle native view
+    // resizes, so when the final size of the widget is known it'll resize
+    // itself. In the meantime use window size to make sure the view can be
+    // initialized properly.
+    Evas* evas = evas_object_evas_get(evas_object_);
+    Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas);
+    ecore_evas_geometry_get(ee, 0, 0, &width, &height);
+    CHECK(width > 0 && height > 0);
+  }
 
   WebContents::CreateParams params(context_->browser_context());
   params.context = GetContentImageObject();
+  params.initial_size = gfx::Size(width, height);
   web_contents_.reset(WebContents::Create(params));
   web_contents_delegate_.reset(new WebContentsDelegateEfl(this));
   web_contents_->SetDelegate(web_contents_delegate_.get());
 
-  bool callback_handled = false;
-  SmartCallback<EWebViewCallbacks::WebProcessCrashed>().call(&callback_handled);
-  if (!callback_handled)
-    LoadHTMLString(kRendererCrashedHTMLMessage, NULL, last_url);
+  back_forward_list_.reset(
+    new tizen_webview::BackForwardList(web_contents_->GetController()));
+
+  LOG(INFO) << "Initial WebContents size: " << params.initial_size.ToString();
 }
 
 #if defined(OS_TIZEN_MOBILE) && !defined(EWK_BRINGUP)
index d653733..53732cf 100644 (file)
@@ -445,6 +445,8 @@ class EWebView {
   void HandleRendererProcessCrash();
 
  private:
+   void InitializeContent();
+
 #if defined(OS_TIZEN_MOBILE) && !defined(EWK_BRINGUP)
   static void cameraResultCb(service_h request, service_h reply,
     service_result_e result, void* data);