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

stderr output from native app ff2mpv: libswresample: 4.10.100 -> 4.7.100 #109

Open
Melechtna opened this issue Nov 11, 2023 · 14 comments
Open
Labels
B:chromium Support for Chromium-based browsers B:firefox Firefox-specific issues and functionality bug help wanted P:linux upstream

Comments

@Melechtna
Copy link

Melechtna commented Nov 11, 2023

Describe the bug

I'm given this error when trying to use the extension, but mpv and yt-dlp works in the terminal just fine.

Reproduction steps

Steps to reproduce the behavior:

  1. Find a video
  2. right click
  3. select 'Play with MPV(W)'
  4. See error in console

Expected behavior

It to just launch in MPV as usual

Platform information

  • OS information: NixOS Unstable
  • Firefox version:119
  • MPV version: 0.36.0
  • youtube-dl version: [email protected] [b634ba742] (pip)
@Melechtna Melechtna added the bug-candidate maybe a bug; not confirmed label Nov 11, 2023
@woodruffw
Copy link
Owner

Thanks for the report. Can you send an example URL that fails to play?

I strongly suspect that this is a distribution level problem (I don't know much about NixOS, but I know they do weird things to paths that Firefox native messaging extensions may depend on).

Another possible candidate: https://bbs.archlinux.org/viewtopic.php?id=287741

@Melechtna
Copy link
Author

Thanks for the report. Can you send an example URL that fails to play?

I strongly suspect that this is a distribution level problem (I don't know much about NixOS, but I know they do weird things to paths that Firefox native messaging extensions may depend on).

Another possible candidate: https://bbs.archlinux.org/viewtopic.php?id=287741

All of them fail to play, but specifically through the extension, MPV itself works just fine, as does yt-dlp. Doesn't matter if it's from Youtube, Odysee, or PornHub. I don't entirely see how the forum post you linked to is related.

@woodruffw
Copy link
Owner

I don't entirely see how the forum post you linked to is related.

I didn't go through it fully, it's just another recent example of someone having issues with MPV with a similar stderr readout.

Can you share a bit more about your host? What's your $PATH (redacted if necessary), and does the behavior change if you spawn Firefox from an interactive shell versus from a desktop launcher?

@Melechtna
Copy link
Author

Melechtna commented Nov 12, 2023

$PATH: /home/user/.local/bin:/home/user/bin:/run/wrappers/bin:/home/user/.local/share/flatpak/exports/bin:/var/lib/flatpak/exports/bin:/home/user/.nix-profile/bin:/nix/profile/bin:/home/user/.local/state/nix/profile/bin:/etc/profiles/per-user/user/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin

No, it behaves the same in a terminal or through the default launcher. I can provide my nix config if that might help, but if you don't understand them, this may not help. I HAD been installing your script through this https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/applications/misc/ff2mpv/default.nix#L29 but it didn't seem to work at all using it, and just running the install.sh worked fine until recently.

@woodruffw
Copy link
Owner

Got it. I'm a bit stumped then: some users have previously reported problems where yt-dlp or youtube-dl wasn't on the $PATH that Firefox was spawned with, but that doesn't seem to be the issue here.

Does anything stand out in your system logs? The only other thing I can think of is some sandboxing change that kills native extensions (this has been a problem for Fedora users I believe, not sure if it applies to NixOS).

I can provide my nix config if that might help, but if you don't understand them, this may not help.

Others might have the same issue, so IMO it's worth pasting here for indexing purposes.

@Melechtna
Copy link
Author

Melechtna commented Nov 12, 2023

Got it. I'm a bit stumped then: some users have previously reported problems where yt-dlp or youtube-dl wasn't on the $PATH that Firefox was spawned with, but that doesn't seem to be the issue here.

Does anything stand out in your system logs? The only other thing I can think of is some sandboxing change that kills native extensions (this has been a problem for Fedora users I believe, not sure if it applies to NixOS).

I can provide my nix config if that might help, but if you don't understand them, this may not help.

Others might have the same issue, so IMO it's worth pasting here for indexing purposes.

NixOS doesn't necessarily sandbox, it wraps, which isn't quite the same concept, and again, it was working until recently.

As for my config, here it is minus a few things that aren't relevant/sensitive

https://pastebin.com/fAYv2GXK

@woodruffw
Copy link
Owner

NixOS doesn't necessarily sandbox, it wraps, which isn't quite the same concept, and again, it was working until recently.

Got it. The Fedora implementation is built on AppArmor (I think), so if Nix doesn't use that then it isn't relevant.

If it was working until recently and the extension itself hasn't changed (which it shouldn't have, since I haven't made any releases in a while), then I'm inclined to go back to the original theory and say that this is something environmental or otherwise unique to a recent change in NixOS (it isn't affecting me on Ubuntu LTS). But we'll leave this open and see.

@Melechtna
Copy link
Author

NixOS doesn't necessarily sandbox, it wraps, which isn't quite the same concept, and again, it was working until recently.

Got it. The Fedora implementation is built on AppArmor (I think), so if Nix doesn't use that then it isn't relevant.

If it was working until recently and the extension itself hasn't changed (which it shouldn't have, since I haven't made any releases in a while), then I'm inclined to go back to the original theory and say that this is something environmental or otherwise unique to a recent change in NixOS (it isn't affecting me on Ubuntu LTS). But we'll leave this open and see.

Given the error looks like a library conflict with libswresample, probably you aren't seeing the error because Ubuntu is perpetually WAY out of date just to be annoying. I wish it were easier to get a more detailed error report from Firefox, but that's all it gives me in its console when I try to run the extension, and I'd have to go through the arduous task of getting a dev build setup to get anything in an actual terminal since -g doesn't seem to want to work when launching it, even though gdb works just fine on the system. Guess I could just launch it through gdb directly, give me a few.

@Melechtna
Copy link
Author

Melechtna commented Nov 12, 2023

And now my head just hurts, running it in gdb, it functioned without issue.

Edit: Okay, there's something extra fucky going on. If you run it from the .firefox-wrapped executable, rather than the firefox shortcut, it magically just works, but I don't even have the slightest clue how that even makes sense.

Edit2: to clarify, most applications have a simple link, I.E. type firefox in the console to launch it, that links to the actual executable, which in this case is .firefox-wrapped. The link breaks it, the proper executable makes it function fine, and given it's a simple soft link, that doesn't even make sense.

@woodruffw woodruffw added P:linux B:firefox Firefox-specific issues and functionality labels Nov 12, 2023
@tianze0926
Copy link

tianze0926 commented Nov 21, 2023

And now my head just hurts, running it in gdb, it functioned without issue.

Edit: Okay, there's something extra fucky going on. If you run it from the .firefox-wrapped executable, rather than the firefox shortcut, it magically just works, but I don't even have the slightest clue how that even makes sense.

Edit2: to clarify, most applications have a simple link, I.E. type firefox in the console to launch it, that links to the actual executable, which in this case is .firefox-wrapped. The link breaks it, the proper executable makes it function fine, and given it's a simple soft link, that doesn't even make sense.

Thanks for your discovery! Based on this I found that the issue comes from the firefox wrapper adding ffmpeg libs to LD_LIBRARY_PATH, whose version is different from that of mpv's ffmpeg.

First of all, realpath $(which firefox) is a symlink that points to a shell script, which adds tons of libraries to LD_LIBRARY_PATH, including ffmpeg:

$ cat $(realpath $(which firefox)) | grep ffmpeg
LD_LIBRARY_PATH=${LD_LIBRARY_PATH/':''/nix/store/b1c4w2g6lrmwadx7gz2g0vaznbb6dha1-ffmpeg-5.1.3-lib/lib64'':'/':'}
LD_LIBRARY_PATH='/nix/store/b1c4w2g6lrmwadx7gz2g0vaznbb6dha1-ffmpeg-5.1.3-lib/lib64'$LD_LIBRARY_PATH
LD_LIBRARY_PATH=${LD_LIBRARY_PATH/':''/nix/store/b1c4w2g6lrmwadx7gz2g0vaznbb6dha1-ffmpeg-5.1.3-lib/lib'':'/':'}
LD_LIBRARY_PATH='/nix/store/b1c4w2g6lrmwadx7gz2g0vaznbb6dha1-ffmpeg-5.1.3-lib/lib'$LD_LIBRARY_PATH

Then I bisected the libraries and located ffmpeg. That makes sense since libswresample is part of ffmpeg.

As for the workaround, I haven't used this extension so I can't provide a detailed solution. I was trying to launch mpv through uri scheme from firefox when I encountered this problem.

Update: Here is my workaround, which overwrites LD_LIBRARY_PATH in the desktop entry script.

@woodruffw
Copy link
Owner

Thanks for your discovery! Based on this I found that the issue comes from the firefox wrapper adding ffmpeg libs to LD_LIBRARY_PATH, whose version is different from that of mpv's ffmpeg.

Wow, what a mess. Thank you for debugging this @tianze0926!

@woodruffw
Copy link
Owner

Note: another option specifically for ff2mpv here is probably to unset LD_LIBRARY_PATH, since we shouldn't need any of Firefox's specific overrides anyways.

@woodruffw
Copy link
Owner

I'm folding #98 into this, see #98 (comment) for context.

@woodruffw woodruffw added upstream bug B:chromium Support for Chromium-based browsers help wanted and removed bug-candidate maybe a bug; not confirmed needs information labels Jan 14, 2024
@1sixth
Copy link

1sixth commented Jan 27, 2024

Based on this I found that the issue comes from the firefox wrapper adding ffmpeg libs to LD_LIBRARY_PATH, whose version is different from that of mpv's ffmpeg.

I've unpinned the ffmpeg used by mpv in NixOS/nixpkgs#265069. Now they should use the same ffmpeg (ffmpeg_6). Can you confirm if the workaround is still necessary?

BTW, there is no need to run install.sh on NixOS. Just do this:

programs.firefox = {
    enable = true;
    nativeMessagingHosts.packages = [ pkgs.ff2mpv ];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B:chromium Support for Chromium-based browsers B:firefox Firefox-specific issues and functionality bug help wanted P:linux upstream
Projects
None yet
Development

No branches or pull requests

4 participants