Bug 1505862 - Send the interleaved WR display list dump to logcat. r=kats
authorWR Updater Bot <graphics-team@mozilla.staktrace.com>
Fri, 09 Nov 2018 02:57:29 +0000
changeset 445363 c898249d585f090b16e75c66d710ea5aa5a0e64b
parent 445362 a85717115906b0d7803c3d6cf3d2950fdc865269
child 445364 b338ffcbe226d324845264b0c7c1146fca1cadcd
push id35015
push userdluca@mozilla.com
push dateFri, 09 Nov 2018 17:45:20 +0000
treeherdermozilla-central@2f1158e5e0ce [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1505862
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1505862 - Send the interleaved WR display list dump to logcat. r=kats Using the gfx.webrender.dl.dump-* prefs is supposed to print a display list dump with the gecko and WR display items appropriately interleaved. However on Android the gecko items get sent to logcat via printf_stderr, and the WR display items get sent to stderr, and so get lost. This makes the WR items also go to logcat so that they show up properly. Depends on D11421 Differential Revision: https://phabricator.services.mozilla.com/D11422
gfx/webrender_bindings/cbindgen.toml
gfx/webrender_bindings/src/bindings.rs
--- a/gfx/webrender_bindings/cbindgen.toml
+++ b/gfx/webrender_bindings/cbindgen.toml
@@ -34,9 +34,9 @@ derive_eq = true
 
 [enum]
 add_sentinel = true
 derive_helper_methods = true
 
 [defines]
 "target_os = windows" = "XP_WIN"
 "target_os = macos" = "XP_MACOSX"
-
+"target_os = android" = "ANDROID"
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -1,16 +1,20 @@
 use std::ffi::{CStr, CString};
+use std::io::Cursor;
 use std::{mem, slice, ptr, env};
 use std::path::PathBuf;
 use std::rc::Rc;
 use std::cell::RefCell;
 use std::sync::Arc;
 use std::sync::atomic::{AtomicUsize, Ordering};
+use std::ops::Range;
 use std::os::raw::{c_void, c_char, c_float};
+#[cfg(target_os = "android")]
+use std::os::raw::{c_int};
 use gleam::gl;
 
 use webrender::api::*;
 use webrender::{ReadPixelsFormat, Renderer, RendererOptions, ThreadListener};
 use webrender::{ExternalImage, ExternalImageHandler, ExternalImageSource};
 use webrender::DebugFlags;
 use webrender::{ApiRecordingReceiver, BinaryRecorder};
 use webrender::{AsyncPropertySampler, PipelineInfo, SceneBuilderHooks};
@@ -27,16 +31,21 @@ use nsstring::nsAString;
 #[cfg(target_os = "windows")]
 use dwrote::{FontDescriptor, FontWeight, FontStretch, FontStyle};
 
 #[cfg(target_os = "macos")]
 use core_foundation::string::CFString;
 #[cfg(target_os = "macos")]
 use core_graphics::font::CGFont;
 
+extern "C" {
+    #[cfg(target_os = "android")]
+    fn __android_log_write(prio: c_int, tag: *const c_char, text: *const c_char) -> c_int;
+}
+
 /// The unique id for WR resource identification.
 static NEXT_NAMESPACE_ID: AtomicUsize = AtomicUsize::new(1);
 
 fn next_namespace_id() -> IdNamespace {
     IdNamespace(NEXT_NAMESPACE_ID.fetch_add(1, Ordering::Relaxed) as u32)
 }
 
 /// Whether a border should be antialiased.
@@ -2553,19 +2562,36 @@ pub extern "C" fn wr_dp_push_box_shadow(
 
 #[no_mangle]
 pub extern "C" fn wr_dump_display_list(state: &mut WrState,
                                        indent: usize,
                                        start: *const usize,
                                        end: *const usize) -> usize {
     let start = unsafe { start.as_ref().cloned() };
     let end = unsafe { end.as_ref().cloned() };
-    state.frame_builder
-         .dl_builder
-         .print_display_list(indent, start, end)
+    let range = Range { start, end };
+    let mut sink = Cursor::new(Vec::new());
+    let index = state.frame_builder
+                     .dl_builder
+                     .emit_display_list(indent, range, &mut sink);
+
+    // For Android, dump to logcat instead of stderr. This is the same as
+    // what printf_stderr does on the C++ side.
+
+    #[cfg(target_os = "android")]
+    unsafe {
+        __android_log_write(4 /* info */,
+                            CString::new("Gecko").unwrap().as_ptr(),
+                            CString::new(sink.into_inner()).unwrap().as_ptr());
+    }
+
+    #[cfg(not(target_os = "android"))]
+    eprint!("{}", String::from_utf8(sink.into_inner()).unwrap());
+
+    index
 }
 
 #[no_mangle]
 pub unsafe extern "C" fn wr_api_finalize_builder(state: &mut WrState,
                                                  content_size: &mut LayoutSize,
                                                  dl_descriptor: &mut BuiltDisplayListDescriptor,
                                                  dl_data: &mut WrVecU8) {
     let frame_builder = mem::replace(&mut state.frame_builder,