Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glib2 2.72.0 causes "Empty response" #878

Closed
tummychow opened this issue Mar 23, 2022 · 46 comments
Closed

glib2 2.72.0 causes "Empty response" #878

tummychow opened this issue Mar 23, 2022 · 46 comments
Labels
bug Something isn't working

Comments

@tummychow
Copy link

Describe the bug
Opening any epub causes foliate to show "Could not open file" with this output:

(com.github.johnfactotum.Foliate:16547): Gjs-WARNING **: 23:22:45.931: JS ERROR: Error: Empty Response
_init/<@resource:///com/github/johnfactotum/Foliate/js/epubView.js:623:57
_handleAction@resource:///com/github/johnfactotum/Foliate/js/epubView.js:886:22
_init/<@resource:///com/github/johnfactotum/Foliate/js/epubView.js:617:18
main@resource:///com/github/johnfactotum/Foliate/js/main.js:478:24
run@resource:///org/gnome/gjs/modules/script/package.js:206:19
@/usr/bin/foliate:9:17

To Reproduce
Open any epub with glib2 2.72.0

Version:
This is with Arch Linux's foliate 2.6.4-1 and glib2 2.72.0-1. Downgrading to Arch's glib2 2.70.4-2 fixes the issue. Honestly, I have no idea why. From past foliate issues, I assumed some other gtk package was involved (eg webkit2gtk 2.36.0-1 to 2.34.6-1, gjs 2:1.70.2-1 to 2:1.70.1-2, js78 78.15.0-4 to 78.15.0-3) but those downgrades don't fix it; only the glib2 downgrade has any effect.

@tummychow tummychow added the bug Something isn't working label Mar 23, 2022
@ksdrummer
Copy link

ksdrummer commented Mar 23, 2022

I confirm that I have the exact same bug on arch : foliate 2.6.4-1 and glib2 2.72.0-1.

(com.github.johnfactotum.Foliate:362831): Gjs-WARNING **: 17:27:09.374: JS ERROR: Error: Empty Response _init/<@resource:///com/github/johnfactotum/Foliate/js/epubView.js:623:57 _handleAction@resource:///com/github/johnfactotum/Foliate/js/epubView.js:886:22 _init/<@resource:///com/github/johnfactotum/Foliate/js/epubView.js:617:18 main@resource:///com/github/johnfactotum/Foliate/js/main.js:478:24 run@resource:///org/gnome/gjs/modules/script/package.js:206:19 @/usr/bin/foliate:9:17

@johnfactotum
Copy link
Owner

For some reason I can't seem to reproduce this. Have glib2 2.72.0-1. Built both 2.6.4 and master and all seems fine.

@tummychow
Copy link
Author

tummychow commented Mar 24, 2022

Interesting... I tried a few other downgrades thinking maybe glib2 was a red herring, but these also have no effect:

  • glib-networking 1:2.72.0-1 to 1:2.70.1-1
  • gobject-introspection-runtime 1.72.0-1 to 1.70.0-5
  • tracker3 3.3.0-1 to 3.2.1-2
  • gtk3 1:3.24.33-2 to 1:3.24.33-1

I'm not sure how something low in the stack (like glib2) could cause this error. Any additional debugging I can do to help?

@johnfactotum
Copy link
Owner

I don't really have any idea. But here's a somewhat minimal script for reproducing the problem:

#!/usr/bin/gjs
const fetchURI = 'file:///home/user/test'
const pageURI = 'file:///usr/share/com.github.johnfactotum.Foliate/assets/epub-viewer.html'

imports.gi.versions.Gtk = '3.0'
imports.gi.versions.WebKit2 = '4.0'
const { Gtk, WebKit2 } = imports.gi

const app = new Gtk.Application({ application_id: 'org.gtk.Example' })

const script = `fetch('${fetchURI}').then(res => res.text()).then(text => alert(text))`

app.connect('activate', () => {
    const win = new Gtk.ApplicationWindow({ application: app })
    const webView = new WebKit2.WebView({
        settings: new WebKit2.Settings({
            enable_write_console_messages_to_stdout: true,
            enable_developer_extras: true,
            allow_universal_access_from_file_urls: true,
        }),
    })
    webView.connect('load-changed', (_, event) =>
        event === WebKit2.LoadEvent.FINISHED
            ? webView.run_javascript(script, null, () => {}) : null)
    webView.load_uri(pageURI)
    win.add(webView)
    win.show_all()
})

app.run([])

To run this script you first need to make sure that /home/user/test exists by running, say, echo "Hello" > /home/user/test. The pageURI on the second line can be change to point to whatever local HTML page you have (in case Foliate isn't installed on the default location). If it alerts "Hello", then it works. Otherwise you would see the "Empty response" error either logged in the terminal or in WebKit's devtools console.

If one can reproduce with this GJS example, then it's probably a good idea to try to reproduce it in C as well and submit a bug to the WebKitGTK devs.

@tummychow
Copy link
Author

tummychow commented Mar 24, 2022

Hmm, running through those steps (with echo "Hello" > /mnt/home/test) gives me this output:

CONSOLE SECURITY ERROR Cross origin requests are only supported for HTTP.
CONSOLE JS ERROR Fetch API cannot load file:///mnt/home/test due to access control checks.
CONSOLE JS ERROR Unhandled Promise Rejection: TypeError: Load failed

which seems... like an error, but not quite the same as the "Empty response" error. Downgrading glib2 does fix it; the window shows a "Hello" alert with this output instead:

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

I'll see about filing that upstream bug.

edit: https://bugs.webkit.org/show_bug.cgi?id=238347

@johnfactotum
Copy link
Owner

Perhaps it's related to how your filesystem is set up, as I still cannot reproduce it.

In any case, in the future we really want to stop making requests to files, which is not only unreliable, but also insecure, and bad for performance as the whole file is loaded in memory. Instead it should either set up a local server, or somehow get a File object.

@ksdrummer
Copy link

I don't know if it's really useful, but the script gave me the same output...

@tummychow
Copy link
Author

Yeah I'm also going to investigate miscellaneous filesystem and DNS related things. glib2 2.72.0 has other peculiar behaviors on my system (eg the GTK file picker no longer shows mountpoints in the "other locations" list) which seem to be in the same ballpark as this. There must be something that makes the file:// request "look" cross-origin that's specific to my setup.

@johackim
Copy link

johackim commented Mar 26, 2022

Temporary solution on Arch Linux with the downgrade command :

sudo downgrade glib2=2.70.4-1

@kauesena
Copy link

kauesena commented Mar 31, 2022

I'm on Arch and @johackim's suggestion solved it for me. It did not work simply by opening foliate as soon as I downgraded, I had to open a specific file. I do not have the downgrade package, but I used the native command:

pacman -U https://archive.archlinux.org/packages/g/glib2/glib2-2.70.4-1-x86_64.pkg.tar.zst

And then added

IgnorePkg=glib2

to /etc/pacman.conf.

@truealex
Copy link

truealex commented Apr 5, 2022

I confirm there is a bug. if I roll back to the previous version of glibc, after rebooting, my desktop and taskbar do not appear. How to read books now?

@Kandelai
Copy link

Kandelai commented Apr 7, 2022

I rolled back using @johackim solution and Foliate worked for me as well, using Garuda Linux/Arch.

@lhirlimann
Copy link

strace.log.gz

Strace log of the issue on fedora 36 if it can help.

@Kandelai
Copy link

Appears with the latest Arch updates, downgrading glib2 no longer works, thus no YacReader, also, still doesn't work with latest glib2 2.72.0-1. Running in terminal gets me;

'YACReader: error while loading shared libraries: libicuuc.so.70: cannot open shared object file: No such file or directory'

@FedericoCeratto
Copy link

FWIW the bug seems to appear on Debian as well but I cannot reproduce it on my hosts using glib 2.72.1

@thebiblelover7
Copy link

I can reproduce this too

@tummychow
Copy link
Author

tummychow commented Apr 22, 2022

Some more investigation updates:

@archisman-panigrahi
Copy link
Contributor

I cannot reproduce this issue with glib2 2.72.1-1 in Arch Linux MATE, and EndeavourOS KDE. Is this issue specific to GNOME?

@moll
Copy link

moll commented Apr 22, 2022

I can confirm @tummychow's comment that upgrading to glib2 v2.72.1-1 on Arch Linux does not seem to fix the issue.

@bgvaughan
Copy link

I filed a bug for Debian. I'm using Debian Sid with XFCE, not with Gnome, and foliate still doesn't work after updating to glib2 v2.72.1-1.

@Kandelai
Copy link

I am confused, why are users filing bug reports with their distro maintainers? Isn't this an issue for the Foliate maintainer to update Foliate to work with the latest Glib2?

@tummychow
Copy link
Author

@Kandelai pretty sure foliate is already doing the right thing here - it's passing the option that disables cross origin restrictions for file urls. So the fact that it's failing a file url request, with a cross origin error message, certainly looks like an upstream bug. (As I've already said, I don't know how webkit2gtk and glib2 can interact in a way that causes this outcome. My guess is both are at fault in some way and glib2 happened to to be the one that revealed the issue.)

@FedericoCeratto
Copy link

@Kandelai because sometimes bugs are due to interactions between library versions or other OS components and so on and can be fixed by the package maintainer.
[I'm the maintainer of the Debian package]

@eksperimental
Copy link

eksperimental commented Apr 24, 2022

If you are on Arch Linux and you use Cinnamon, DO NOT DOWNGRADE glib2 to 2.70.4-1
Your graphical interface will become unusable.

@adamensler
Copy link

Arch w/ Gnome shell 42 here. Encountered the same issue and found the downgrade trick above worked.

@landfish2102
Copy link

I encountered this bug on Arch, but after deleting the file ~/.local/share/mime/mime.cache, I am now able to open ebooks with foliate 2.6.4 and glib 2.72.1 without problems. WARNING: removing this file may unset all your default applications and filetype associations!

This might provide a workaround for others that can't downgrade glib2.

Based on Michael Catanzaro's comment at https://gitlab.gnome.org/GNOME/glib/-/issues/2639, it appears that the upstream bug is triggered if an application has been set as default for the .html extension, which happens after Firefox is set as the default web browser. Deleting the mime database clears this default, at least temporarily. The following upstream issues are also relevant.

@rokezu
Copy link

rokezu commented May 11, 2022

Just to confirm the same bug on Arch Linux as fellow users of that distribution and same versions, hopefully a solution will be found. I'd rather not mess with mime.cache or downgrades of core packages.

@eksperimental
Copy link

Just to confirm the same bug on Arch Linux as fellow users of that distribution and same versions, hopefully a solution will be found. I'd rather not mess with mime.cache or downgrades of core packages.

Do not downgrade! I messed up my environment.

You can install it from Snap store, it works just fine.

@Vednier
Copy link

Vednier commented May 16, 2022

Oh well, having same problem on Ubuntu Mate 22.04 with same glib 2.72, so its global problem. Interestingly enough, Atril - Mate's standard viewer for PDF and epub have lost ability to show epub file at same time.

@kauesena
Copy link

kauesena commented May 18, 2022

Since my last comment, I have reinstalled ArchLinux and I can now use Foliate 2.6.4 (the most recent) with glib2 2.72.1-1 via the package foliate from the Community repository.

@winteriscariot
Copy link

Since my last comment, I have reinstalled ArchLinux and I can now use Foliate 2.6.4 (the most recent) with glib2 2.72.1-1 via the package foliate from the Community repository.

can you re-check this? I just did the same on my Arch install and i'm still getting the same error. Please verify your versions: i don't believe this issue is resolved. (there's been no update to Foliate that i can tell, nor to glib2, that would have fixed anything)

@archisman-panigrahi
Copy link
Contributor

archisman-panigrahi commented May 19, 2022 via email

@kauesena
Copy link

@winteriscariot I have just rechecked the versions (using pacman -Qi) of glib2 and Foliate and they are respectively 2.72.1-1 and 2.6.4-1.

@kauesena
Copy link

If you (plural) need me to provide more information on my system or run any test, I'd be happy to oblige. I can think of no difference between the current installation from the previous one except that I've replaced the common kernel with the zen kernel and that I've started using LVM. However, I do not think such changes would interfere. The change must be of the sort @apandada1 mentioned.

@jeois

This comment was marked as outdated.

@rokezu
Copy link

rokezu commented May 20, 2022

Well, I deleted mime.cache (mine was a file from 2011, not updated since then‽) and Foliate is working again, rebooted several times for a couple of days now, still working. File associations and such for other apps didn't change. I have no idea what is going on with these modern apps that resort to such convoluted ways to do an fopen() but well... So far this is working for me? In my case I just wanted to double check some ePubs from Humble Bundle that can't be opened correctly in my e-reader or with Calibre, and Foliate opened and formatted it successfully! I'm reading a comic at the moment. 😄📖

@argosatcore
Copy link

argosatcore commented May 24, 2022

Well, I deleted mime.cache (mine was a file from 2011, not updated since then‽) and Foliate is working again, rebooted several times for a couple of days now, still working. File associations and such for other apps didn't change. I have no idea what is going on with these modern apps that resort to such convoluted ways to do an fopen() but well... So far this is working for me? In my case I just wanted to double check some ePubs from Humble Bundle that can't be opened correctly in my e-reader or with Calibre, and Foliate opened and formatted it successfully! I'm reading a comic at the moment. smilebook

This worked for me too on Debian Sid. After deleting ~/.local/share/mime/mime.cache, foliate started working again without any apparent issues. However, if I restore the deleted mime.cache file or recreate it via update-mime-database ~/.local/share/mime, the issue resurfaces.

@chillycuz
Copy link

I have the same exact experience as @argosatcore on fully updated Arch Linux 5.18, including failure after update-mime-database.

@feute
Copy link

feute commented Jun 22, 2022

I started having this issue on Fedora 36 with everything up to date. Deleting ~/.local/share/mime/mime.cache solved it.

@Arkoprovo1996
Copy link

I started having this issue on Fedora 36 with everything up to date. Deleting ~/.local/share/mime/mime.cache solved it.

Wow, yes. I did too, on Manjaro and it fixed the issue. Thanks so much!! ♥

@okias
Copy link
Contributor

okias commented Jun 28, 2022

on Debian removing ~/.local/share/mime/mime.cache also helped. It's nice we have workaround.

@truealex
Copy link

truealex commented Jun 28, 2022

on latest Arch advice to delete mime.cache file does not work
sorry, it works

@argosatcore
Copy link

This issue has been fixed on Debian Sid. [1] It looks like the culprit was glib and is now fixed on version 2.72.3.

After running update-mime-database ~/.local/share/mime, I can now open EPUB files without a problem, and foliate works as expected.


[1] See: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1009669

@wenzezlaus
Copy link

As well, on Arch the issue is fixed with glib2 updated to v. 2.72.3

@kauesena
Copy link

kauesena commented Jul 6, 2022

I second what @wenzezlaus reported. Somehow the issue reappeared to me some days ago but updating the system getting glib2.72.3 made foliate work again.

@johnfactotum
Copy link
Owner

Closing as it seems to have been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests