Surface synchronization: Don't kill renderer on invariants violations

With this CL, we no longer kill the renderer when there is a surface
invariants violation. Often that state can be recovered from on resize,
for example or maybe even on the next frame.

TBR=fsamuel@chromium.org

(cherry picked from commit 5d086e08de608ded2e571b49024646c339006ad8)

Bug: 791154, 672962
Change-Id: I21d0827b54932c636b015c96f3db97a3d2d58dac
Reviewed-on: https://chromium-review.googlesource.com/926913
Reviewed-by: Saman Sami <samans@chromium.org>
Commit-Queue: Fady Samuel <fsamuel@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#537910}
Reviewed-on: https://chromium-review.googlesource.com/944245
Reviewed-by: Fady Samuel <fsamuel@chromium.org>
Cr-Commit-Position: refs/branch-heads/3325@{#641}
Cr-Branched-From: bc084a8b5afa3744a74927344e304c02ae54189f-refs/heads/master@{#530369}
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
index 5618cc8..71e8797 100644
--- a/content/browser/renderer_host/render_widget_host_impl.cc
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -14,6 +14,7 @@
 #include "base/bind.h"
 #include "base/command_line.h"
 #include "base/containers/hash_tables.h"
+#include "base/debug/dump_without_crashing.h"
 #include "base/i18n/rtl.h"
 #include "base/lazy_instance.h"
 #include "base/location.h"
@@ -2709,17 +2710,24 @@
   if (local_surface_id == last_local_surface_id_ &&
       SurfacePropertiesMismatch(new_surface_properties,
                                 last_surface_properties_)) {
+    std::string error = base::StringPrintf(
+        "[OOPIF? %d] %s\n", view_ && view_->IsRenderWidgetHostViewChildFrame(),
+        new_surface_properties.ToDiffString(last_surface_properties_).c_str());
+    LOG(ERROR) << "Surface invariants violation: " << error;
+
     static auto* crash_key = base::debug::AllocateCrashKeyString(
         "surface-invariants-violation", base::debug::CrashKeySize::Size256);
-    base::debug::ScopedCrashKeyString key_value(
-        crash_key,
-        base::StringPrintf(
-            "[OOPIF? %d] %s\n",
-            view_ && view_->IsRenderWidgetHostViewChildFrame(),
-            new_surface_properties.ToDiffString(last_surface_properties_)
-                .c_str()));
-    bad_message::ReceivedBadMessage(
-        GetProcess(), bad_message::RWH_SURFACE_INVARIANTS_VIOLATION);
+    base::debug::ScopedCrashKeyString key_value(crash_key, error);
+    base::debug::DumpWithoutCrashing();
+
+    if (view_) {
+      frame.metadata.begin_frame_ack.has_damage = false;
+      view_->OnDidNotProduceFrame(frame.metadata.begin_frame_ack);
+    }
+    std::vector<viz::ReturnedResource> resources =
+        viz::TransferableResource::ReturnResources(frame.resource_list);
+    renderer_compositor_frame_sink_->DidReceiveCompositorFrameAck(resources);
+
     return;
   }