Bug 1457387 - Remove WrExternalLogHandler r=jrmuizel
authorsotaro <sotaro.ikeda.g@gmail.com>
Fri, 04 May 2018 14:31:32 +0900
changeset 416930 00725c5bba29576e85aab17f4d18a67ef2f5c327
parent 416896 f579a28444855e4ccbf45c8c82f9bb78ebbe822b
child 416931 6d837b6dd6b4ce4efa804515bd95d747f27c9110
push id33944
push usercsabou@mozilla.com
push dateFri, 04 May 2018 17:38:13 +0000
treeherdermozilla-central@01db12b43ae7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1457387
milestone61.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 1457387 - Remove WrExternalLogHandler r=jrmuizel
Cargo.lock
gfx/ipc/GPUParent.cpp
gfx/webrender_bindings/Cargo.toml
gfx/webrender_bindings/WebRenderAPI.cpp
gfx/webrender_bindings/WebRenderAPI.h
gfx/webrender_bindings/src/bindings.rs
gfx/webrender_bindings/src/lib.rs
gfx/webrender_bindings/webrender_ffi_generated.h
xpcom/build/XPCOMInit.cpp
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2321,17 +2321,16 @@ dependencies = [
 [[package]]
 name = "webrender_bindings"
 version = "0.1.0"
 dependencies = [
  "app_units 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "dwrote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "env_logger 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "euclid 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "foreign-types 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "gleam 0.4.32 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "thread_profiler 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "webrender 0.57.2",
 ]
--- a/gfx/ipc/GPUParent.cpp
+++ b/gfx/ipc/GPUParent.cpp
@@ -253,18 +253,16 @@ GPUParent::RecvInit(nsTArray<GfxPrefSett
     FT_Library library = Factory::NewFTLibrary();
     MOZ_ASSERT(library);
     Factory::SetFTLibrary(library);
   }
 #endif
 
   // Make sure to do this *after* we update gfxVars above.
   if (gfxVars::UseWebRender()) {
-    wr::WebRenderAPI::InitRustLogForGpuProcess();
-
     wr::RenderThread::Start();
   }
 
   VRManager::ManagerInit();
   // Send a message to the UI process that we're done.
   GPUDeviceData data;
   RecvGetDeviceStatus(&data);
   Unused << SendInitComplete(data);
@@ -488,18 +486,16 @@ GPUParent::ActorDestroy(ActorDestroyReas
   }
   dom::VideoDecoderManagerParent::ShutdownVideoBridge();
   CompositorThreadHolder::Shutdown();
   VRListenerThreadHolder::Shutdown();
   // There is a case that RenderThread exists when gfxVars::UseWebRender() is false.
   // This could happen when WebRender was fallbacked to compositor.
   if (wr::RenderThread::Get()) {
     wr::RenderThread::ShutDown();
-
-    wr::WebRenderAPI::ShutdownRustLogForGpuProcess();
   }
   Factory::ShutDown();
 #if defined(XP_WIN)
   DeviceManagerDx::Shutdown();
 #endif
   LayerTreeOwnerTracker::Shutdown();
   gfxVars::Shutdown();
   gfxConfig::Shutdown();
--- a/gfx/webrender_bindings/Cargo.toml
+++ b/gfx/webrender_bindings/Cargo.toml
@@ -6,17 +6,16 @@ license = "MPL-2.0"
 
 [dependencies]
 rayon = "1"
 thread_profiler = "0.1.1"
 euclid = { version = "0.17", features = ["serde"] }
 app_units = "0.6"
 gleam = "0.4.32"
 log = "0.4"
-env_logger = "0.5"
 
 [dependencies.webrender]
 path = "../webrender"
 version = "0.57.2"
 default-features = false
 features = ["capture"]
 
 [target.'cfg(target_os = "windows")'.dependencies]
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -269,32 +269,16 @@ TransactionWrapper::AppendTransformPrope
 void
 TransactionWrapper::UpdateScrollPosition(const wr::WrPipelineId& aPipelineId,
                                          const layers::FrameMetrics::ViewID& aScrollId,
                                          const wr::LayoutPoint& aScrollPosition)
 {
   wr_transaction_scroll_layer(mTxn, aPipelineId, aScrollId, aScrollPosition);
 }
 
-/*static*/ void
-WebRenderAPI::InitRustLogForGpuProcess()
-{
-  MOZ_ASSERT(XRE_IsGPUProcess());
-  // Initialize rust log for gpu process.
-  // Rust log of non-gpu process is initialized by Servo_Initialize()
-  mozilla::wr::wr_init_log_for_gpu_process();
-}
-
-/*static*/ void
-WebRenderAPI::ShutdownRustLogForGpuProcess()
-{
-  MOZ_ASSERT(XRE_IsGPUProcess());
-  mozilla::wr::wr_shutdown_log_for_gpu_process();
-}
-
 /*static*/ already_AddRefed<WebRenderAPI>
 WebRenderAPI::Create(layers::CompositorBridgeParent* aBridge,
                      RefPtr<widget::CompositorWidget>&& aWidget,
                      const wr::WrWindowId& aWindowId,
                      LayoutDeviceIntSize aSize)
 {
   MOZ_ASSERT(aBridge);
   MOZ_ASSERT(aWidget);
--- a/gfx/webrender_bindings/WebRenderAPI.h
+++ b/gfx/webrender_bindings/WebRenderAPI.h
@@ -168,20 +168,16 @@ public:
   /// This can be called on the compositor thread only.
   static already_AddRefed<WebRenderAPI> Create(layers::CompositorBridgeParent* aBridge,
                                                RefPtr<widget::CompositorWidget>&& aWidget,
                                                const wr::WrWindowId& aWindowId,
                                                LayoutDeviceIntSize aSize);
 
   already_AddRefed<WebRenderAPI> CreateDocument(LayoutDeviceIntSize aSize, int8_t aLayerIndex);
 
-  // Redirect the WR's log to gfxCriticalError/Note.
-  static void InitRustLogForGpuProcess();
-  static void ShutdownRustLogForGpuProcess();
-
   already_AddRefed<WebRenderAPI> Clone();
 
   wr::WindowId GetId() const { return mId; }
 
   bool HitTest(const wr::WorldPoint& aPoint,
                wr::WrPipelineId& aOutPipelineId,
                layers::FrameMetrics::ViewID& aOutScrollId,
                gfx::CompositorHitTestInfo& aOutHitInfo);
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -1,9 +1,8 @@
-use std::env;
 use std::ffi::{CStr, CString};
 use std::{mem, slice};
 use std::path::PathBuf;
 use std::ptr;
 use std::rc::Rc;
 use std::sync::Arc;
 use std::os::raw::{c_void, c_char, c_float};
 use gleam::gl;
@@ -15,18 +14,16 @@ use webrender::DebugFlags;
 use webrender::{ApiRecordingReceiver, BinaryRecorder};
 use webrender::{AsyncPropertySampler, PipelineInfo, SceneBuilderHooks};
 use webrender::{ProgramCache, UploadMethod, VertexUsageHint};
 use thread_profiler::register_thread_with_profiler;
 use moz2d_renderer::Moz2dImageRenderer;
 use app_units::Au;
 use rayon;
 use euclid::SideOffsets2D;
-use log;
-use env_logger::filter::Filter;
 
 #[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;
@@ -478,17 +475,16 @@ extern "C" {
     fn gfx_use_wrench() -> bool;
     fn gfx_wr_resource_path_override() -> *const c_char;
     // TODO: make gfx_critical_error() work.
     // We still have problem to pass the error message from render/render_backend
     // thread to main thread now.
     #[allow(dead_code)]
     fn gfx_critical_error(msg: *const c_char);
     fn gfx_critical_note(msg: *const c_char);
-    fn gecko_printf_stderr_output(msg: *const c_char);
 }
 
 struct CppNotifier {
     window_id: WrWindowId,
 }
 
 unsafe impl Send for CppNotifier {}
 
@@ -2351,88 +2347,16 @@ extern "C" {
                                format: ImageFormat,
                                tile_size: *const u16,
                                tile_offset: *const TileOffset,
                                dirty_rect: *const DeviceUintRect,
                                output: MutByteSlice)
                                -> bool;
 }
 
-type ExternalMessageHandler = unsafe extern "C" fn(msg: *const c_char);
-
-struct WrExternalLogHandler {
-    error_msg: ExternalMessageHandler,
-    warn_msg: ExternalMessageHandler,
-    info_msg: ExternalMessageHandler,
-    debug_msg: ExternalMessageHandler,
-    trace_msg: ExternalMessageHandler,
-    inner: Filter
-}
-
-impl WrExternalLogHandler {
-    fn new() -> Self {
-        use env_logger::filter::Builder;
-
-        // Filter cration code is borrowed from Servo_Initialize()
-        let mut builder = Builder::new();
-        let default_level = if cfg!(debug_assertions) { "warn" } else { "error" };
-        let builder = match env::var("RUST_LOG") {
-            Ok(v) => builder.parse(&v),
-            _ => builder.parse(default_level),
-        };
-
-        WrExternalLogHandler {
-            error_msg: gfx_critical_note,
-            warn_msg: gecko_printf_stderr_output,
-            info_msg: gecko_printf_stderr_output,
-            debug_msg: gecko_printf_stderr_output,
-            trace_msg: gecko_printf_stderr_output,
-            inner: builder.build(),
-        }
-    }
-
-    fn init() -> Result<(), log::SetLoggerError> {
-        let logger = Self::new();
-
-        log::set_max_level(logger.inner.filter());
-        log::set_boxed_logger(Box::new(logger))
-    }
-}
-
-impl log::Log for WrExternalLogHandler {
-    fn enabled(&self, metadata : &log::Metadata) -> bool {
-        self.inner.enabled(metadata)
-    }
-
-    fn log(&self, record: &log::Record) {
-        if self.enabled(record.metadata()) {
-            // For file path and line, please check the record.location().
-            let msg = CString::new(format!("WR: {}",
-                                           record.args())).unwrap();
-            unsafe {
-                match record.level() {
-                    log::Level::Error => (self.error_msg)(msg.as_ptr()),
-                    log::Level::Warn => (self.warn_msg)(msg.as_ptr()),
-                    log::Level::Info => (self.info_msg)(msg.as_ptr()),
-                    log::Level::Debug => (self.debug_msg)(msg.as_ptr()),
-                    log::Level::Trace => (self.trace_msg)(msg.as_ptr()),
-                }
-            }
-        }
-    }
-
-    fn flush(&self) {
-    }
-}
-
-#[no_mangle]
-pub extern "C" fn wr_init_log_for_gpu_process() {
-    WrExternalLogHandler::init().unwrap();
-}
-
 #[no_mangle]
 pub extern "C" fn wr_shutdown_log_for_gpu_process() {
     // log does not support shutdown
 }
 
 #[no_mangle]
 pub extern "C" fn wr_root_scroll_node_id() -> usize {
     // The PipelineId doesn't matter here, since we just want the numeric part of the id
--- a/gfx/webrender_bindings/src/lib.rs
+++ b/gfx/webrender_bindings/src/lib.rs
@@ -8,17 +8,16 @@ extern crate webrender;
 extern crate euclid;
 extern crate app_units;
 extern crate gleam;
 extern crate rayon;
 extern crate thread_profiler;
 
 #[macro_use]
 extern crate log;
-extern crate env_logger;
 
 #[cfg(target_os = "windows")]
 extern crate dwrote;
 
 #[cfg(target_os = "macos")]
 extern crate core_foundation;
 #[cfg(target_os = "macos")]
 extern crate core_graphics;
--- a/gfx/webrender_bindings/webrender_ffi_generated.h
+++ b/gfx/webrender_bindings/webrender_ffi_generated.h
@@ -953,18 +953,16 @@ extern void apz_register_sampler(WrWindo
 
 extern void apz_register_updater(WrWindowId aWindowId);
 
 extern void apz_run_updater(WrWindowId aWindowId);
 
 extern void apz_sample_transforms(WrWindowId aWindowId,
                                   Transaction *aTransaction);
 
-extern void gecko_printf_stderr_output(const char *aMsg);
-
 extern void gecko_profiler_register_thread(const char *aName);
 
 extern void gecko_profiler_unregister_thread();
 
 extern void gfx_critical_error(const char *aMsg);
 
 extern void gfx_critical_note(const char *aMsg);
 
@@ -1349,20 +1347,16 @@ WR_FUNC;
 WR_INLINE
 void wr_dp_save(WrState *aState)
 WR_FUNC;
 
 WR_INLINE
 void wr_dump_display_list(WrState *aState)
 WR_FUNC;
 
-WR_INLINE
-void wr_init_log_for_gpu_process()
-WR_FUNC;
-
 extern bool wr_moz2d_render_cb(ByteSlice aBlob,
                                uint32_t aWidth,
                                uint32_t aHeight,
                                ImageFormat aFormat,
                                const uint16_t *aTileSize,
                                const TileOffset *aTileOffset,
                                const DeviceUintRect *aDirtyRect,
                                MutByteSlice aOutput);
--- a/xpcom/build/XPCOMInit.cpp
+++ b/xpcom/build/XPCOMInit.cpp
@@ -713,16 +713,18 @@ NS_InitMinimalXPCOM()
   NS_LogInit();
   NS_InitAtomTable();
 
   // We don't have the arguments by hand here.  If logging has already been
   // initialized by a previous call to LogModule::Init with the arguments
   // passed, passing (0, nullptr) is alright here.
   mozilla::LogModule::Init(0, nullptr);
 
+  GkRust_Init();
+
   nsresult rv = nsThreadManager::get().Init();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   // Init the SystemGroup for dispatching main thread runnables.
   SystemGroup::InitStatic();