plugin: log dylib load + service init/poll to debug missing singleton registration

This commit is contained in:
Damocles 2026-05-03 17:39:52 +02:00
parent f7c485c881
commit 545812cf75
5 changed files with 43 additions and 1 deletions

23
plugin/Cargo.lock generated
View file

@ -97,6 +97,16 @@ dependencies = [
"unicode-segmentation",
]
[[package]]
name = "ctor"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3429e8f8e3ce0ffe475c411850f70468c70d7a87d2ac3d15dd44703fb885aede"
dependencies = [
"link-section",
"linktime-proc-macro",
]
[[package]]
name = "cxx"
version = "1.0.194"
@ -328,6 +338,18 @@ dependencies = [
"cc",
]
[[package]]
name = "link-section"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea2c24837c4fd5ab6a31d64133eae954f5199247523cf29586117e85245c0dd3"
[[package]]
name = "linktime-proc-macro"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a44cd706ff0d503ee32b2071166510ca27e281228de10cd3aa8d35ff94560f81"
[[package]]
name = "memchr"
version = "2.8.0"
@ -338,6 +360,7 @@ checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
name = "nova-plugin"
version = "0.1.0"
dependencies = [
"ctor",
"cxx",
"cxx-qt",
"cxx-qt-build",

View file

@ -16,6 +16,7 @@ cast_sign_loss = "allow"
cxx = "1.0"
cxx-qt = "0.8.1"
cxx-qt-lib = { version = "0.8.1", features = ["qt_full"] }
ctor = "0.13"
libc = "0.2"
[build-dependencies]

View file

@ -77,6 +77,7 @@ impl Default for CpuServiceRust {
impl cxx_qt::Initialize for qobject::CpuService {
fn initialize(mut self: Pin<&mut Self>) {
eprintln!("[nova-plugin] CpuService::initialize");
let max_freqs = read_core_max_freqs();
let types = infer_core_types(&max_freqs);
@ -93,6 +94,7 @@ impl cxx_qt::Initialize for qobject::CpuService {
impl qobject::CpuService {
fn poll(mut self: Pin<&mut Self>) {
eprintln!("[nova-plugin] CpuService::poll");
let curr = cpu::read_stat();
let freqs = cpu::read_core_freqs();
let prev = self.as_ref().rust().prev_stat.clone();

View file

@ -1,3 +1,10 @@
pub mod cpu_service;
pub mod stats;
pub mod system_stats;
// Fires when the .so is dlopen'd. Tells us the plugin file actually loaded,
// independent of whether qml_register_types runs.
#[ctor::ctor(unsafe)]
fn on_dylib_load() {
eprintln!("[nova-plugin] dylib loaded (libNovaStats.so)");
}

View file

@ -116,6 +116,7 @@ impl Default for SystemStatsServiceRust {
impl cxx_qt::Initialize for qobject::SystemStatsService {
fn initialize(mut self: Pin<&mut Self>) {
eprintln!("[nova-plugin] SystemStatsService::initialize");
let backend = gpu::detect_gpu();
let available = !matches!(backend, gpu::GpuBackend::None);
let vendor = match &backend {
@ -132,6 +133,7 @@ impl cxx_qt::Initialize for qobject::SystemStatsService {
impl qobject::SystemStatsService {
fn poll(mut self: Pin<&mut Self>) {
eprintln!("[nova-plugin] SystemStatsService::poll");
self.as_mut().poll_mem();
self.as_mut().poll_temp();
self.as_mut().poll_gpu();
@ -142,8 +144,15 @@ impl qobject::SystemStatsService {
}
fn poll_mem(mut self: Pin<&mut Self>) {
let Some(m) = mem::read_meminfo() else { return };
let Some(m) = mem::read_meminfo() else {
eprintln!("[nova-plugin] poll_mem: read_meminfo returned None");
return;
};
let pct = m.percent as i32;
eprintln!(
"[nova-plugin] poll_mem: pct={pct} used={:.2}gb total={:.2}gb",
m.used_gb, m.total_gb
);
self.as_mut().set_mem_percent(pct);
self.as_mut().set_mem_used_gb(m.used_gb);
self.as_mut().set_mem_total_gb(m.total_gb);