From a7116925bf1bd2da246321ea98c77912a17ca9c5 Mon Sep 17 00:00:00 2001 From: Sophie Herold Date: Thu, 8 Feb 2024 00:32:09 +0100 Subject: [PATCH] debug: Add more tracing for initial operations --- src/application.rs | 3 +++ src/decoder/formats/glycin_proxy.rs | 2 ++ src/main.rs | 6 ++++++ src/widgets/image.rs | 3 +++ src/widgets/image/rendering.rs | 10 ++++++++++ 5 files changed, 24 insertions(+) diff --git a/src/application.rs b/src/application.rs index 6ea0bea..f65a6be 100644 --- a/src/application.rs +++ b/src/application.rs @@ -75,11 +75,13 @@ mod imp { // Overrides GApplication vfuncs impl ApplicationImpl for LpApplication { fn startup(&self) { + log::trace!("Startup"); self.parent_startup(); LpShyBin::ensure_type(); } fn activate(&self) { + log::trace!("Activate"); let application = self.obj(); let window = LpWindow::new(&*application); window.present(); @@ -87,6 +89,7 @@ mod imp { // Handles opening files from the command line or other applications fn open(&self, files: &[gio::File], _hint: &str) { + log::trace!("Open {} file(s)", files.len()); let application = self.obj(); let win = LpWindow::new(&*application); win.image_view().set_images_from_files(files.to_vec()); diff --git a/src/decoder/formats/glycin_proxy.rs b/src/decoder/formats/glycin_proxy.rs index a40b100..2e8d4d5 100644 --- a/src/decoder/formats/glycin_proxy.rs +++ b/src/decoder/formats/glycin_proxy.rs @@ -48,6 +48,7 @@ impl Glycin { let (next_frame_send, next_frame_recv) = async_channel::bounded(2); updater.clone().spawn_error_handled(async move { + log::trace!("Setting up loader"); let mut image_request = glycin::Loader::new(file); #[cfg(feature = "disable-glycin-sandbox")] @@ -56,6 +57,7 @@ impl Glycin { image_request.cancellable(cancellable_); let image = image_request.request().await?; + log::trace!("Image info received"); let mut metadata: Metadata = Metadata::default(); metadata.set_image_info(image.info().details.clone()); diff --git a/src/main.rs b/src/main.rs index 6645ae0..f71d6dd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -81,13 +81,19 @@ fn main() -> glib::ExitCode { log_builder.init(); + log::debug!("Logger initialized"); + setlocale(LocaleCategory::LcAll, ""); bindtextdomain("loupe", config::LOCALEDIR).unwrap(); textdomain("loupe").unwrap(); + log::trace!("gettext initialized"); + gio::resources_register( &gio::Resource::from_data(&glib::Bytes::from_static(GRESOURCE_BYTES)).unwrap(), ); + log::trace!("Gio resources registered"); + LpApplication::new().run() } diff --git a/src/widgets/image.rs b/src/widgets/image.rs index b392140..0b5c25d 100644 --- a/src/widgets/image.rs +++ b/src/widgets/image.rs @@ -232,6 +232,9 @@ mod imp { pub(super) widget_dimensions: Cell<(i32, i32)>, pub(super) scaling: Cell, pub(super) surface_signals: OnceCell, + + /// Number of snapshots created, debug only + pub(super) nth_snapshot: Cell, } #[glib::object_subclass] diff --git a/src/widgets/image/rendering.rs b/src/widgets/image/rendering.rs index c9f0f9d..3da1b10 100644 --- a/src/widgets/image/rendering.rs +++ b/src/widgets/image/rendering.rs @@ -65,6 +65,12 @@ impl WidgetImpl for imp::LpImage { let applicable_zoom = self.applicable_zoom(); + let nth_snaphot = self.nth_snapshot.get() + 1; + if nth_snaphot < 3 { + self.nth_snapshot.set(nth_snaphot); + log::trace!("Creating snapshot #{nth_snaphot}"); + } + let scaling_filter = if obj.metadata().is_svg() { // Looks better in SVG animations and avoids rendering issues gsk::ScalingFilter::Linear @@ -125,6 +131,10 @@ impl WidgetImpl for imp::LpImage { .add_to_snapshot(snapshot, applicable_zoom, &render_options); snapshot.restore(); + + if nth_snaphot < 3 { + log::trace!("Snapshot #{nth_snaphot} created"); + } } fn measure(&self, orientation: gtk::Orientation, _for_size: i32) -> (i32, i32, i32, i32) {