Bug 1585801 - Fixing crash when folder is not writable and refactored logic. r=jrmuizel

Differential Revision: https://phabricator.services.mozilla.com/D48999

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kris Taeleman 2019-10-15 17:03:22 +00:00
Родитель ffc7835642
Коммит 8205a49853
15 изменённых файлов: 55 добавлений и 21 удалений

Просмотреть файл

@ -4066,7 +4066,9 @@ nsDOMWindowUtils::SetCompositionRecording(bool aValue) {
NS_IMETHODIMP
nsDOMWindowUtils::SetTransactionLogging(bool aValue) {
Preferences::SetBool("gfx.webrender.debug.log-transactions", aValue);
if (WebRenderBridgeChild* wrbc = GetWebRenderBridge()) {
wrbc->SetTransactionLogging(aValue);
}
return NS_OK;
}

Просмотреть файл

@ -73,6 +73,9 @@ parent:
// Save the frame capture to disk
async Capture();
// Enable/Disable transaction logging
async SetTransactionLogging(bool aValue);
// Replacement for PCompositorBridge::SyncWithCompositor, but for WR. We need
// it on PWebRenderBridge because it associated with a particular top-level
// window, and PCompositorBridge doesn't allow doing that in a secure manner.

Просмотреть файл

@ -633,5 +633,9 @@ void WebRenderBridgeChild::DeallocResourceShmem(RefCountedShmem& aShm) {
void WebRenderBridgeChild::Capture() { this->SendCapture(); }
void WebRenderBridgeChild::SetTransactionLogging(bool aValue) {
this->SendSetTransactionLogging(aValue);
}
} // namespace layers
} // namespace mozilla

Просмотреть файл

@ -181,6 +181,7 @@ class WebRenderBridgeChild final : public PWebRenderBridgeChild,
void DeallocResourceShmem(RefCountedShmem& aShm);
void Capture();
void SetTransactionLogging(bool aValue);
private:
friend class CompositorBridgeChild;

Просмотреть файл

@ -2019,6 +2019,14 @@ mozilla::ipc::IPCResult WebRenderBridgeParent::RecvCapture() {
return IPC_OK();
}
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvSetTransactionLogging(
const bool& aValue) {
if (!mDestroyed) {
mApis[wr::RenderRoot::Default]->SetTransactionLogging(aValue);
}
return IPC_OK();
}
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvSyncWithCompositor() {
FlushSceneBuilds();
if (RefPtr<WebRenderBridgeParent> root = GetRootWebRenderBridgeParent()) {

Просмотреть файл

@ -151,6 +151,7 @@ class WebRenderBridgeParent final
mozilla::ipc::IPCResult RecvClearCachedResources() override;
mozilla::ipc::IPCResult RecvScheduleComposite() override;
mozilla::ipc::IPCResult RecvCapture() override;
mozilla::ipc::IPCResult RecvSetTransactionLogging(const bool&) override;
mozilla::ipc::IPCResult RecvSyncWithCompositor() override;
mozilla::ipc::IPCResult RecvSetConfirmedTargetAPZC(

Просмотреть файл

@ -600,7 +600,6 @@ static void WebRenderDebugPrefChangeCallback(const char* aPrefName, void*) {
GFX_WEBRENDER_DEBUG(".disable-gradient-prims",
wr::DebugFlags_DISABLE_GRADIENT_PRIMS)
GFX_WEBRENDER_DEBUG(".obscure-images", wr::DebugFlags_OBSCURE_IMAGES)
GFX_WEBRENDER_DEBUG(".log-transactions", wr::DebugFlags_LOG_TRANSACTIONS)
#undef GFX_WEBRENDER_DEBUG
gfx::gfxVars::SetWebRenderDebugFlags(flags.bits);

Просмотреть файл

@ -584,6 +584,10 @@ void WebRenderAPI::Capture() {
wr_api_capture(mDocHandle, path, bits);
}
void WebRenderAPI::SetTransactionLogging(bool aValue) {
wr_api_set_transaction_logging(mDocHandle, aValue);
}
void WebRenderAPI::SetCompositionRecorder(
UniquePtr<layers::WebRenderCompositionRecorder> aRecorder) {
class SetCompositionRecorderEvent final : public RendererEvent {

Просмотреть файл

@ -264,6 +264,7 @@ class WebRenderAPI final {
layers::SyncHandle GetSyncHandle() const { return mSyncHandle; }
void Capture();
void SetTransactionLogging(bool aValue);
void SetCompositionRecorder(
UniquePtr<layers::WebRenderCompositionRecorder> aRecorder);

Просмотреть файл

@ -1864,6 +1864,14 @@ pub extern "C" fn wr_api_capture(
dh.api.save_capture(path, bits);
}
#[no_mangle]
pub extern "C" fn wr_api_set_transaction_logging(
dh: &mut DocumentHandle,
aValue: bool
) {
dh.api.send_debug_cmd(DebugCommand::SetTransactionLogging(aValue));
}
#[cfg(target_os = "windows")]
fn read_font_descriptor(
bytes: &mut WrVecU8,

Просмотреть файл

@ -67,9 +67,8 @@ pub struct LogRecorder {
}
impl LogRecorder {
pub fn new(dest: &PathBuf) -> LogRecorder {
let file = File::create(dest).unwrap();
LogRecorder { file }
pub fn new(dest: &PathBuf) -> Option<Box<LogRecorder>> {
Some(Box::new(LogRecorder { file: File::create(dest).ok()? }))
}
}

Просмотреть файл

@ -701,7 +701,7 @@ pub struct RenderBackend {
notifier: Box<dyn RenderNotifier>,
recorder: Option<Box<dyn ApiRecordingReceiver>>,
logrecorder: Option<Box<dyn ApiRecordingReceiver>>,
logrecorder: Option<Box<LogRecorder>>,
sampler: Option<Box<dyn AsyncPropertySampler + Send>>,
size_of_ops: Option<MallocSizeOfOps>,
debug_flags: DebugFlags,
@ -956,18 +956,6 @@ impl RenderBackend {
status = match self.api_rx.recv() {
Ok(msg) => {
if self.debug_flags.contains(DebugFlags::LOG_TRANSACTIONS) {
if let None = self.logrecorder {
let current_time = time::now_utc().to_local();
let name = format!("wr-log-{}.log",
current_time.strftime("%Y%m%d_%H%M%S").unwrap()
);
self.logrecorder = Some(Box::new(LogRecorder::new(&PathBuf::from(name))))
}
} else {
self.logrecorder = None;
}
if let Some(ref mut r) = self.logrecorder {
r.write_msg(frame_counter, &msg);
}
@ -1180,6 +1168,21 @@ impl RenderBackend {
// before the `PublishDocument` messages sent by `load_capture`.
return RenderBackendStatus::Continue;
}
DebugCommand::SetTransactionLogging(value) => {
match (value, self.logrecorder.as_ref()) {
(true, None) => {
let current_time = time::now_utc().to_local();
let name = format!("wr-log-{}.log",
current_time.strftime("%Y%m%d_%H%M%S").unwrap()
);
self.logrecorder = LogRecorder::new(&PathBuf::from(name));
},
(false, _) => self.logrecorder = None,
_ => (),
};
return RenderBackendStatus::Continue;
}
DebugCommand::ClearCaches(mask) => {
self.resource_cache.clear(mask);
return RenderBackendStatus::Continue;

Просмотреть файл

@ -2791,7 +2791,8 @@ impl Renderer {
fn handle_debug_command(&mut self, command: DebugCommand) {
match command {
DebugCommand::EnableDualSourceBlending(_) => {
DebugCommand::EnableDualSourceBlending(_) |
DebugCommand::SetTransactionLogging(_) => {
panic!("Should be handled by render backend");
}
DebugCommand::FetchDocuments |

Просмотреть файл

@ -775,6 +775,8 @@ pub enum DebugCommand {
/// Causes the low priority scene builder to pause for a given amount of milliseconds
/// each time it processes a transaction.
SimulateLongLowPrioritySceneBuild(u32),
// Logs transactions to a file for debugging purposes
SetTransactionLogging(bool),
}
#[derive(Clone, Deserialize, Serialize)]
@ -1140,7 +1142,6 @@ bitflags! {
const DISABLE_TEXT_PRIMS = 1 << 22;
const DISABLE_GRADIENT_PRIMS = 1 << 23;
const OBSCURE_IMAGES = 1 << 24;
const LOG_TRANSACTIONS = 1 << 25;
}
}

Просмотреть файл

@ -675,7 +675,6 @@ pref("gfx.webrender.debug.picture-caching", false);
pref("gfx.webrender.debug.primitives", false);
pref("gfx.webrender.debug.small-screen", false);
pref("gfx.webrender.debug.obscure-images", false);
pref("gfx.webrender.debug.log-transactions", false);
pref("accessibility.warn_on_browsewithcaret", true);