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

xdg-document-portal leaks FDs #1008

Closed
felinira opened this issue Apr 24, 2023 · 6 comments
Closed

xdg-document-portal leaks FDs #1008

felinira opened this issue Apr 24, 2023 · 6 comments
Labels
bug needs diagnosis Root cause of the issue needs to be diagnosed portal: documents Issues with the documents portal

Comments

@felinira
Copy link

Closing an app while having open files causes those FDs to leak.

Steps to reproduce:

  • Open amberol for example, select a file to play
  • Press Ctrl+q
  • Look at lsof -p $(pidof xdg-document-portal)

The file that was opened is still being held open, in contrast to when the app closes the file by itself (eg. by switching to the next track)

@Redecorating
Copy link

Seems related to #689, where having these files kept open makes it impossible to unmount filesystems

@xioren
Copy link

xioren commented May 2, 2023

I have done a little poking around to see if I could learn more about it. One thing I will note is that not all Flatpak apps cause this issue. For me the issue is with MPV, other apps such as my image viewer do not cause an issue. I'm hoping for more discussion on this as it is a particularly egregious imo

@rusty-snake
Copy link

Guess because your image viewer has filesystem= permission and dies not usw Portals.

@xioren
Copy link

xioren commented May 2, 2023

You're probably right. I don't know who on the dev team needs to be made aware of this but we need to be moving mountains to fix this. It has been a problem since at least 2021 and it doesn't seem like any attempt has been made to address what is from my perspective a five alarm fire bug. I have looked through the source code but I don't know C that well and I haven't seen anything obvious that stands out. Here are some other threads with discussions: #4303, #689, #994, #902, #721.

@xioren
Copy link

xioren commented May 3, 2023

@GeorgesStavracas can you provide some insight? For the methods contained in org.freedesktop.portal.Documents, those are to be called by the program wishing to use xdg-document-portal correct? If so then each program would need to specify whether they want a file for a session or indefinitely by using the persistent argument.

IN h o_path_fd:
open file descriptor for the file to add

IN b reuse_existing:
whether to reuse an existing document store entry for the file

IN b persistent:
whether to add the file only for this session or permanently

OUT s doc_id:
the ID of the file in the document store

I'm trying to piggy back off what @teohhanhui referenced in #4303. In my case every time I open a file, a new export shows up in /run/user/$UID/doc/. So right now I have five exports and counting for the same file in the MPV directory, and they stay there even after closing the flatpak. I'm trying to figure out if that's normal behavior.

@GeorgesStavracas GeorgesStavracas added bug portal: documents Issues with the documents portal needs diagnosis Root cause of the issue needs to be diagnosed labels Oct 3, 2023
@GeorgesStavracas
Copy link
Member

Duplicate of #689

@GeorgesStavracas GeorgesStavracas marked this as a duplicate of #689 Oct 4, 2023
@GeorgesStavracas GeorgesStavracas closed this as not planned Won't fix, can't repro, duplicate, stale Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs diagnosis Root cause of the issue needs to be diagnosed portal: documents Issues with the documents portal
Projects
Status: Triaged
Development

No branches or pull requests

5 participants