taffybar / gtk-sni-tray

A StatusNotifierHost widget written using the gtk+3 bindings for haskell provided by gi-gtk.
BSD 3-Clause "New" or "Revised" License
36 stars 2 forks source link

Fix scale. #29

Open kurnevsky opened 3 years ago

kurnevsky commented 3 years ago

Gtk requires size to be >0.

I get the following error periodically:

Jul 28 00:34:14 dell taffybar-linux-[265044]: gdk_pixbuf_scale_simple: assertion 'dest_width > 0' failed
Jul 28 00:34:14 dell taffybar[265044]: [DEBUG] StatusNotifier.Tray - targetW: 0, targetH: 1
Jul 28 00:34:14 dell taffybar[265044]: [DEBUG] StatusNotifier.Tray - Scaling pb to 1, actualW: 59, actualH: 96, scaledW: 0, scaledH: 1
Jul 28 00:34:14 dell taffybar[265044]: [DEBUG] StatusNotifier.Tray - targetW: 1, targetH: 1
Jul 28 00:34:14 dell taffybar[265044]: [DEBUG] StatusNotifier.Tray - Scaling pb to 1, actualW: 16, actualH: 16, scaledW: 1, scaledH: 1
Jul 28 00:34:14 dell taffybar[265044]: [DEBUG] StatusNotifier.Tray - targetW: 1, targetH: 1
Jul 28 00:34:14 dell taffybar[265044]: [DEBUG] StatusNotifier.Tray - Scaling pb to 1, actualW: 1, actualH: 1, scaledW: 1, scaledH: 1
Jul 28 00:34:14 dell taffybar[265044]: [DEBUG] StatusNotifier.Tray - targetW: 1, targetH: 1
Jul 28 00:34:14 dell taffybar[265044]: [DEBUG] StatusNotifier.Tray - Scaling pb to 1, actualW: 1, actualH: 1, scaledW: 1, scaledH: 1
Jul 28 00:34:14 dell taffybar[265044]: [DEBUG] StatusNotifier.Tray - targetW: 1, targetH: 1
Jul 28 00:34:14 dell taffybar[265044]: [DEBUG] StatusNotifier.Tray - Scaling pb to 1, actualW: 1, actualH: 1, scaledW: 1, scaledH: 1
Jul 28 00:34:14 dell taffybar[265044]: [DEBUG] StatusNotifier.Tray - targetW: 1, targetH: 1
Jul 28 00:34:14 dell taffybar[265044]: [DEBUG] StatusNotifier.Tray - Scaling pb to 1, actualW: 1, actualH: 1, scaledW: 1, scaledH: 1
Jul 28 00:34:14 dell taffybar[265044]: [DEBUG] StatusNotifier.Tray - targetW: 1, targetH: 1
Jul 28 00:34:14 dell taffybar[265044]: [DEBUG] StatusNotifier.Tray - Scaling pb to 1, actualW: 1, actualH: 1, scaledW: 1, scaledH: 1
Jul 28 00:34:14 dell taffybar[265044]: [DEBUG] StatusNotifier.Tray - targetW: 1, targetH: 1
Jul 28 00:34:14 dell taffybar[265044]: [DEBUG] StatusNotifier.Tray - Scaling pb to 1, actualW: 1, actualH: 1, scaledW: 1, scaledH: 1
Jul 28 00:34:14 dell taffybar[265044]: [DEBUG] StatusNotifier.Tray - targetW: 1, targetH: 1
Jul 28 00:34:14 dell taffybar[265044]: [DEBUG] StatusNotifier.Tray - Scaling pb to 1, actualW: 1, actualH: 1, scaledW: 1, scaledH: 1
Jul 28 00:34:14 dell taffybar[265044]: [WARNING] System.Taffybar.Widget.Generic.AutoSizeImage - Allocating image: size 1, width 1,  height 1, aw: 1, ah: 1, pbw: 59 pbh: 96
Jul 28 00:34:14 dell taffybar[265044]: [WARNING] StatusNotifier.Tray - Unable to scale pixbuf
Jul 28 00:34:14 dell taffybar-linux-[265044]: gdk_pixbuf_scale_simple: assertion 'dest_width > 0' failed
Jul 28 00:34:14 dell taffybar[265044]: [DEBUG] StatusNotifier.Tray - targetW: 0, targetH: 1
Jul 28 00:34:14 dell taffybar[265044]: [DEBUG] StatusNotifier.Tray - Scaling pb to 1, actualW: 59, actualH: 96, scaledW: 0, scaledH: 1
Jul 28 00:34:14 dell taffybar[265044]: [DEBUG] StatusNotifier.Tray - targetW: 1, targetH: 1
Jul 28 00:34:14 dell taffybar[265044]: [DEBUG] StatusNotifier.Tray - Scaling pb to 1, actualW: 1, actualH: 1, scaledW: 1, scaledH: 1
Jul 28 00:34:14 dell taffybar[265044]: [WARNING] System.Taffybar.Widget.Generic.AutoSizeImage - Allocating image: size 1, width 1,  height 1, aw: 1, ah: 1, pbw: 59 pbh: 96
Jul 28 00:34:14 dell taffybar[265044]: [WARNING] StatusNotifier.Tray - Unable to scale pixbuf
Jul 28 00:34:14 dell taffybar-linux-[265044]: gdk_pixbuf_scale_simple: assertion 'dest_width > 0' failed
Jul 28 00:34:14 dell taffybar[265044]: [DEBUG] StatusNotifier.Tray - targetW: 0, targetH: 1
colonelpanic8 commented 3 years ago

This is probably from a non existent icon. I think a better solution would be to find the root cause of this issue.

kurnevsky commented 3 years ago

But I didn't notice any missing icons - all tray icons work as expected. The problem is that when this happens I have huge icons and taffybar with much bigger height. So looks like they can't be scaled.

colonelpanic8 commented 3 years ago

It's weird that the target Height and Width are both 1. I don't think that should be happening. Why would it be trying to scale things to a single pixel?

kurnevsky commented 3 years ago

No idea, but after this patch it doesn't scale things to 1 pixel. Last time this happened after taffybar restart, but before restart it worked fine. Could it be that right after start taffybar has got wrong height?

kurnevsky commented 3 years ago

It's pidgin icon that causes it. Not right after start, but after some time. Probably after receiving a message... When message is received its icon blinks. So probably when it disappears taffybar can't get it as it's supposed to be empty. And after this fix it's shown as it should.

kurnevsky commented 3 years ago

Here is the icon it sets: https://github.com/philipl/pidgin-indicator/blob/master/icons/hicolor/22x22/status/pidgin-indicator-nothing.png Looks like it's 22x22 pixels, so not sure if it really causes this.

colonelpanic8 commented 3 years ago

It would not be about the icons size. What is being logged is the target size, so the size we are attempting to scale it to. Seems weird that we are trying to scale something to be 1 pixel or 0 pixels. Sounds like maybe the widget is hidden or something when this attempt is made.

colonelpanic8 commented 3 years ago

. The problem is that when this happens I have huge icons and

The reason you have huge icons is that the attempt to scale the icon is failing, and we are falling back to just returning the unscaled pixbuf. The attempt to scale the icon is failing because we are requesting a non-sensical size. We should figure out why we are requesting this non-sensiscal size.

kurnevsky commented 3 years ago

It would not be about the icons size. What is being logged is the target size, so the size we are attempting to scale it to.

Then I don't get it why after this fix I see taffybar with its usual height and correctly scaled icons, bigger than 1 pixel.

btw, I can't reproduce it - it only happened 2 times, but after it happened taffybar had this problem even after restart. Only after I closed pidgin and restarted taffybar it returned to its normal size.

colonelpanic8 commented 3 years ago

Then I don't get it why after this fix I see taffybar with its usual height and correctly scaled icons, bigger than 1 pixel.

Probably because after the 1 pixel resize, the bar immediately resizes and that triggers another automatic resize and then you get the correct size.

My suspicion is that there is some type of degenerate condition at startup.

kurnevsky commented 3 years ago

Just reproduced it - it happens after you receive a message in pidgin and then restart taffybar. @IvanMalison any ideas how to debug this?