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

flatpak-builder builds killed by xdg-desktop-portal due to background restriction #478

Closed
YaLTeR opened this issue Apr 25, 2020 · 9 comments

Comments

@YaLTeR
Copy link
Contributor

YaLTeR commented Apr 25, 2020

My flatpak-builder build was inexplicably getting SIGKILLed seemingly on a time-out. After hours of debugging, I found out that it was getting killed by xdg-desktop-portal. Turns out, the app-id of my manifest was somehow denied background operation (according to permission-viewer) so xdg-desktop-portal was killing bwrap spawned by bwrap spawned by flatpak-builder. I don't recall seeing any GNOME Shell prompt for background operation related to this app-id. Allowing the background operation for the app-id in permission-viewer fixed the issue.

Here's the manifest that I used. sleep 300 was more than enough to trigger the issue.

{
    "app-id" : "org.sourceruns.VideoTrimmer",
    "runtime" : "org.gnome.Platform",
    "runtime-version" : "3.36",
    "sdk" : "org.gnome.Sdk",
    "sdk-extensions" : [
        "org.freedesktop.Sdk.Extension.rust-stable"
    ],
    "command" : "video-trimmer",
    "finish-args" : [
        "--share=ipc",
        "--socket=fallback-x11",
        "--socket=wayland"
    ],
    "build-options" : {
        "append-path" : "/usr/lib/sdk/rust-stable/bin",
        "build-args" : [
            "--share=network"
        ],
        "env" : {
            "CARGO_HOME" : "/run/build/video-trimmer/cargo",
            "RUST_BACKTRACE" : "1",
            "RUST_LOG" : "video-trimmer=debug"
        }
    },
    "cleanup" : [
        "/include",
        "/lib/pkgconfig",
        "/man",
        "/share/doc",
        "/share/gtk-doc",
        "/share/man",
        "/share/pkgconfig",
        "*.la",
        "*.a"
    ],
    "modules" : [
        {
            "name": "ffmpeg",
            "buildsystem": "simple",
            "build-commands": [
                "sleep 300"
            ],
            "config-opts": [
                "--disable-doc",
                "--disable-decoders",
                "--disable-encoders",
                "--disable-devices",
                "--disable-ffplay",
                "--disable-ffprobe",
                "--enable-gpl"
            ],
            "cleanup": [
                "/include",
                "/lib",
                "/share"
            ],
            "sources": [
                {
                    "type": "archive",
                    "url": "https://www.ffmpeg.org/releases/ffmpeg-4.2.2.tar.xz",
                    "sha256": "cb754255ab0ee2ea5f66f8850e1bd6ad5cac1cd855d0a2f4990fb8c668b0d29c"
                }
            ]
        },
        {
            "name" : "video-trimmer",
            "builddir" : true,
            "buildsystem" : "meson",
            "sources" : [
                {
                    "type" : "dir",
                    "path" : "."
                }
            ]
        }
    ]
}
@YaLTeR
Copy link
Contributor Author

YaLTeR commented Apr 25, 2020

As an update, I changed the app-id and did indeed get a Shell dialog asking me whether I want to allow or deny the background operation. According to @barthalion on #flatpak, builds should not be part of this.

@matthiasclasen
Copy link
Contributor

Well, it is a feature to control background activity in flatpaks. If your builds are running in flatpaks, they are affected.

@barthalion
Copy link
Member

This is relatively common problem though. Ideally there should be a way to exclude builds started by flatpak-builder from background activity control.

@gigitux
Copy link

gigitux commented Dec 23, 2020

Thanks for open this issue!

I also add an error log so that it can be found more easily:

Error: module youp: Child process exited with code 137

To reset the permission check the command:

flatpak permission-reset

@kparal
Copy link

kparal commented Feb 24, 2021

I just spent several hours searching for some explanation for why my flatpak-builder exits at random points during compilation with

Error: module gtk2: Child process exited with code 137

and it was really hard to figure out, I found this ticket mostly by accident. Of course, I'm affected by the same issue. The app-id I was using had background operations disallowed, I have no idea why. flatpak permission-reset app-id resolved the problem.

Now, can we please make this more user friendly?

  1. When a process is killed because background operation is disallowed, please print a message to system journal! This will make it much easier to find out what has happened.
  2. It would also be good from users' POV to show a notification Flatpak app XYZ was terminated, because background operations were not allowed or similar.
  3. Do the compilations need to run under the app-id, can't they run under the flatpak-builder ID? It seems really weird to combine these together. I might not want to allow background operations for a certain app, but I still want to be able to compile it...

At least 1) and 2) should be relatively easy to do, I hope, and would improve this situation dramatically. Thanks.

@sudopluto
Copy link

just ran into this issue, i agree that there needs to be a better heads up that this permission needs to be set.

@GeorgesStavracas
Copy link
Member

Since #901 the background monitoring code is more lenient towards background-running apps, and won't kill them on spot, unless users actively disable that. That's enough to cover the use-case of GNOME Builder, although annoyingly, it shows up as a background app while compiling.

@matzipan
Copy link

Still a bit confusing. Came across this today while in GNOME.

While building I got the notification that the application is running in the background. I get the dialog with options "Force quit" and "Allow". At that time, I was still rebuilding so I did not expect my app to be running so I clicked "Force quit".

I spent the next hour debugging why my flatpak-builder space is getting killed at random times.

@j5155
Copy link

j5155 commented May 6, 2024

Would definitely agree that this is still confusing. 4 years later and I just spent the afternoon trying to debug why it was getting killed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants