johnfactotum / foliate

Read e-books in style
https://johnfactotum.github.io/foliate/
GNU General Public License v3.0
6.18k stars 287 forks source link

v2.6.4 snap crashes when opening the catalogs page #1028

Closed soumyaDghosh closed 10 months ago

soumyaDghosh commented 1 year ago

Describe the bug Recently, I updated foliate to version 2.6.4. When I run it I get this..

** (com.github.johnfactotum.Foliate:21295): WARNING **: 20:40:10.389: Could not open /etc/machine-info: Failed to open file “/etc/machine-info”: Permission denied

** (com.github.johnfactotum.Foliate:21295): WARNING **: 20:40:10.389: Could not open /sys/class/dmi/id/chassis_type: Failed to open file “/sys/class/dmi/id/chassis_type”: Permission denied

** (com.github.johnfactotum.Foliate:21295): WARNING **: 20:40:10.390: Could not open /sys/firmware/acpi/pm_profile: Failed to open file “/sys/firmware/acpi/pm_profile”: Permission denied

(process:21454): GLib-GIO-WARNING **: 20:40:10.661: GDBus.Error:org.freedesktop.portal.Error.NotAllowed: This call is not available inside the sandbox

** (WebKitWebProcess:21458): WARNING **: 20:40:10.990: Could not open /etc/machine-info: Failed to open file “/etc/machine-info”: Permission denied

** (WebKitWebProcess:21458): WARNING **: 20:40:10.990: Could not open /sys/class/dmi/id/chassis_type: Failed to open file “/sys/class/dmi/id/chassis_type”: Permission denied

** (WebKitWebProcess:21458): WARNING **: 20:40:10.990: Could not open /sys/firmware/acpi/pm_profile: Failed to open file “/sys/firmware/acpi/pm_profile”: Permission denied

** (WebKitWebProcess:21458): WARNING **: 20:40:10.990: Failed to get atspi registered event listeners: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.60" (uid=1000 pid=21458 comm="/usr/lib/x86_64-linux-gnu/webkit2gtk-4.0/WebKitWeb" label="snap.foliate.foliate (enforce)") interface="org.a11y.atspi.Registry" member="GetRegisteredEvents" error name="(unset)" requested_reply="0" destination=":1.1" (uid=1000 pid=3137 comm="/usr/libexec/at-spi2-registryd --use-gnome-session" label="unconfined")

** (WebKitWebProcess:21457): WARNING **: 20:40:10.999: Could not open /etc/machine-info: Failed to open file “/etc/machine-info”: Permission denied

** (WebKitWebProcess:21457): WARNING **: 20:40:10.999: Could not open /sys/class/dmi/id/chassis_type: Failed to open file “/sys/class/dmi/id/chassis_type”: Permission denied

** (WebKitWebProcess:21457): WARNING **: 20:40:11.000: Could not open /sys/firmware/acpi/pm_profile: Failed to open file “/sys/firmware/acpi/pm_profile”: Permission denied

** (WebKitWebProcess:21457): WARNING **: 20:40:11.001: Failed to get atspi registered event listeners: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.59" (uid=1000 pid=21457 comm="/usr/lib/x86_64-linux-gnu/webkit2gtk-4.0/WebKitWeb" label="snap.foliate.foliate (enforce)") interface="org.a11y.atspi.Registry" member="GetRegisteredEvents" error name="(unset)" requested_reply="0" destination=":1.1" (uid=1000 pid=3137 comm="/usr/libexec/at-spi2-registryd --use-gnome-session" label="unconfined")

CONSOLE SECURITY ERROR The Content Security Policy directive 'sandbox' is ignored when delivered via an HTML meta element.

** (WebKitWebProcess:21456): WARNING **: 20:40:11.008: Failed to get atspi registered event listeners: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.61" (uid=1000 pid=21456 comm="/usr/lib/x86_64-linux-gnu/webkit2gtk-4.0/WebKitWeb" label="snap.foliate.foliate (enforce)") interface="org.a11y.atspi.Registry" member="GetRegisteredEvents" error name="(unset)" requested_reply="0" destination=":1.1" (uid=1000 pid=3137 comm="/usr/libexec/at-spi2-registryd --use-gnome-session" label="unconfined")

** (WebKitWebProcess:21456): WARNING **: 20:40:11.009: Could not open /etc/machine-info: Failed to open file “/etc/machine-info”: Permission denied

** (WebKitWebProcess:21456): WARNING **: 20:40:11.009: Could not open /sys/class/dmi/id/chassis_type: Failed to open file “/sys/class/dmi/id/chassis_type”: Permission denied

** (WebKitWebProcess:21456): WARNING **: 20:40:11.009: Could not open /sys/firmware/acpi/pm_profile: Failed to open file “/sys/firmware/acpi/pm_profile”: Permission denied
CONSOLE SECURITY ERROR The Content Security Policy directive 'sandbox' is ignored when delivered via an HTML meta element.
CONSOLE SECURITY ERROR The Content Security Policy directive 'sandbox' is ignored when delivered via an HTML meta element.

(com.github.johnfactotum.Foliate:21295): Gjs-WARNING **: 20:40:11.107: JS ERROR: Error: TypeError: Load failed
_handleAction@resource:///com/github/johnfactotum/Foliate/js/opds.js:485:50
OpdsClient/<@resource:///com/github/johnfactotum/Foliate/js/opds.js:470:18
main@resource:///com/github/johnfactotum/Foliate/js/main.js:478:24
run@resource:///org/gnome/gjs/modules/script/package.js:206:19
@/snap/foliate/1214/usr/bin/com.github.johnfactotum.Foliate:9:17

(com.github.johnfactotum.Foliate:21295): Gjs-WARNING **: 20:40:11.107: JS ERROR: Error: TypeError: Load failed
_handleAction@resource:///com/github/johnfactotum/Foliate/js/opds.js:485:50
OpdsClient/<@resource:///com/github/johnfactotum/Foliate/js/opds.js:470:18
main@resource:///com/github/johnfactotum/Foliate/js/main.js:478:24
run@resource:///org/gnome/gjs/modules/script/package.js:206:19
@/snap/foliate/1214/usr/bin/com.github.johnfactotum.Foliate:9:17

(com.github.johnfactotum.Foliate:21295): Gjs-WARNING **: 20:40:11.107: JS ERROR: Error: TypeError: Load failed
_handleAction@resource:///com/github/johnfactotum/Foliate/js/opds.js:485:50
OpdsClient/<@resource:///com/github/johnfactotum/Foliate/js/opds.js:470:18
main@resource:///com/github/johnfactotum/Foliate/js/main.js:478:24
run@resource:///org/gnome/gjs/modules/script/package.js:206:19
@/snap/foliate/1214/usr/bin/com.github.johnfactotum.Foliate:9:17

Segmentation fault (core dumped)

To Reproduce Steps to reproduce the behavior:

  1. Go to snap-store & install the snap
  2. Click on the snap icon(it doesn't have one, LOL)
  3. Open the app
  4. See error

Expected behavior Expected it to work at par to the flatpak.

Version:

Additional context As per the commit 1c31610, if your code uses some feature from webkitgtk-6 which aren't available in webkitgtk4, then, your app can't be snapped now. We're working to bring in webkit2gtk-5+(may be a leap to 6) to the gnome-sdk. It's a WIP. Also, your app doesn't show up any icon, which is completely okay, as snapd needs an actual path of the icon, or it needs to be mentioned with icon: data/com.github.johnfactotum.Foliate.svg. You must test your app atleast once, before pushing it to the stable channel. Keep it in the edge channel for atleast a day.

johnfactotum commented 1 year ago

As per the commit https://github.com/johnfactotum/foliate/commit/1c31610cd348021845ab3b3996c38ac51c77ccc6, if your code uses some feature from webkitgtk-6 which aren't available in webkitgtk4, then, your app can't be snapped now.

I don't think this is relevant. The commit is from the gtk4 branch, which is not released anywhere yet, through Snap or otherwise.

Although the snapcraft.yaml lives in the gtk4 branch, it should be building (at least in theory, but I have not tested it myself; see below) from the v2.6.4 tarball, which is tagged to c16a24c14a8b399267bca2130bf54661e930404b from the master branch.

But to avoid confusion, I guess it would be better if a separate repo is made to house the yaml. Similar to Flatpak.

You must test your app atleast once, before pushing it to the stable channel. Keep it in the edge channel for atleast a day.

I have not tested it myself. The Snap package was made by @CapeCrusader321 who claims to have tested it. See https://github.com/johnfactotum/foliate/issues/1017.

soumyaDghosh commented 1 year ago

But to avoid confusion, I guess it would be better if a separate repo is made to house the yaml. Similar to Flatpak.

That'd surely be a better option.

Regarding the main two issues,

  1. Seems like this issue is with OPDS as the logs from terminal sugges. This seems to be the similar issue with #923 & #918. Actually #918 matches more, but the logs match with #923. When you run it graphically for the first time, you're greeted with the library page, which is fine but whenever you move to the catalog page, the above error log will be shown to you. As per my experience with this app, it saves the last position, (I guess). So, when again next time, you try to open the app, it'll open up in the catalog again, causing a crash.
  2. The icon in the snap can be fixed by adding the line in the snapcraft.yaml, which I mentioned earlier. icon: data/com.github.johnfactotum.Foliate.svg
johnfactotum commented 1 year ago

Well, the error message doesn't really say anything. You'd get the "Load Failed" error if you turn off the network, for example. But the segfault is unexpected.

As for the icon, is there a reason why it needs be set manually? This was apparently not needed in the old snapcraft.yaml: https://github.com/johnfactotum/foliate/blob/master/build-aux/snap/snapcraft.yaml

soumyaDghosh commented 1 year ago

Well, the error message doesn't really say anything. You'd get the "Load Failed" error if you turn off the network, for example. But the segfault is unexpected.

Anything else, that I can do to help with debugging?

As for the icon, is there a reason why it needs be set manually? This was apparently not needed in the old snapcraft.yaml: https://github.com/johnfactotum/foliate/blob/master/build-aux/snap/snapcraft.yaml

The previous snap worked simply because it adopted the icon from the metadata, but in the latest version we are talking here v2.6.4, you changed the metainfo file name to usr/share/metainfo/com.github.johnfactotum.Foliate.metainfo.xml, from usr/share/metainfo/com.github.johnfactotum.Foliate.appdata.xml, but the snapcraft.yaml still points towards the same old file. That's also a reason, why the description & summary is needed to mention manually, they are not adopted from the appstream metadata. https://snapcraft.io/docs/using-external-metadata#heading--appstream

Snaps copies the desktop file in a separate folder with the desktop name(the name of the snap, here foliate.desktop and takes a copy of the icon there. https://snapcraft.io/docs/desktop-menu-support

As per the manual copy, latest snap doesn't do it which make the snap being shown as a binary file in YARU ICONS, cause YARU ICONS don't have an icon named foliate. I have given some examples like- firefox, snap-store etc

https://github.com/canonical/firefox-snap/blob/stable/snapcraft.yaml#407 https://github.com/ubuntu-flutter-community/software/blob/main/snap/snapcraft.yaml#L53 https://github.com/ed10vi/fragments/blob/main/snap/snapcraft.yaml#L79 https://github.com/kenvandine/fractal-snap/blob/main/snap/snapcraft.yaml#L7

johnfactotum commented 1 year ago

Anything else, that I can do to help with debugging?

Well, for actual debugging you could try printing the debug messages or use a debugger. Some bugs might require accessing WebKit's devtools to investigate, though, and currently there isn't an easy way to do this for the OPDS client.

But the main question is: assuming that the previous version worked for you, what has changed? Were you using 2.6.3? 2.6.4 is a pretty minor release, and I don't see anything that could possibly cause it to behave differently with regard to the Catalogs page. Or perhaps it's due to the change in the runtime, in which case one could test it by building the old version with the new runtime or the new version with the old one.

But I wouldn't bother, to be honest. I doubt it's something that could be fixed by fiddling with snapcraft.yml. Or even by changing Foliate's own code. There's always been mysterious crashes that I can't even reproduce. And to be honest I don't really want to touch the v2.x branch anymore.

The previous snap worked simply because it adopted the icon from the metadata, but in the latest version we are talking here v2.6.4, you changed the metainfo file name to usr/share/metainfo/com.github.johnfactotum.Foliate.metainfo.xml, from usr/share/metainfo/com.github.johnfactotum.Foliate.appdata.xml, but the snapcraft.yaml still points towards the same old file. That's also a reason, why the description & summary is needed to mention manually, they are not adopted from the appstream metadata.

Well, let's fix the AppData file path, then.

@CapeCrusader321 I guess I will accept your original proposal and transfer the Snap to you. If you could investigate this and other Snap issues that would be great, too (perhaps they could be transferred to the separate repo), as at this point I really have no time or the desire to deal with Snap.

ghost commented 1 year ago

@johnfactotum I am willing to do so and am also ready to solve and investigate this issues

soumyaDghosh commented 1 year ago

But the main question is: assuming that the previous version worked for you, what has changed? Were you using 2.6.3? 2.6.4 is a pretty minor release, and I don't see anything that could possibly cause it to behave differently with regard to the Catalogs page. Or perhaps it's due to the change in the runtime, in which case one could test it by building the old version with the new runtime or the new version with the old one.

I have been using v2.6.2; I didn't update it quite a while. I stopped the update of that app, because I was facing issues with 2.6.3, but TBH, I didn't know much back then, about reporting issues and stuff. Sorry about that.

One more thing about snaps, instead of using a release file, you can point to use a particular tag using source-tag. Also, use the metadata to adopt the summary and description. Use this git repo as source.

ghost commented 1 year ago

@johnfactotum https://github.com/johnfactotum/foliate/issues/1005

puzanov commented 1 year ago

My guess this is not snap issue. I have pretty the same case having installed Foliate from apt on Debian #1021

ghost commented 1 year ago

@soumyaDghosh Can you reproduce this error with flatpak or deb ones ??

soumyaDghosh commented 1 year ago

Currently busy with my exams, sorry about that.

ghost commented 1 year ago

Currently busy with my exams, sorry about that.

Whatever, From my side and my conclusion this is not related in general with snaps and overall is a foliate issue as a whole and thus isnt something to be looked upon by me.

bulksign commented 1 year ago

It's reproduceable with deb (and snap) for me, here is the log output :

(com.github.johnfactotum.Foliate:8174): Gjs-WARNING **: 09:54:08.788: Unhandled promise rejection. To suppress this warning, add an error handler to your promise chain with .catch() or a try-catch block around your await expression. Stack trace of the failed promise: main@resource:///com/github/johnfactotum/Foliate/js/main.js:478:24 run@resource:///org/gnome/gjs/modules/script/package.js:206:19 @/usr/bin/com.github.johnfactotum.Foliate:9:17

soumyaDghosh commented 1 year ago

The latest version of the snap is not crashing any more.