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

Cannot load VLC installed via Flatpak #79

Closed
Mark6O9 opened this issue May 31, 2024 · 13 comments
Closed

Cannot load VLC installed via Flatpak #79

Mark6O9 opened this issue May 31, 2024 · 13 comments
Labels
Bug: API Something isn't working Game: Minecraft Modloader: Forge Severity: Issue Status: Concerning This issue pulls me to different levels of concern Type: Bug Type bug

Comments

@Mark6O9
Copy link

Mark6O9 commented May 31, 2024

My friend and I were going to play around with this mod on their mod pack, but they told me that videos don't work. Me testing it in a single player world showed that videos don't work except images do work. We both think it could just be an issue for Linux and Windows is the only way to get this mod to work. However we also came to the theory that it just needs to be pointed to VLC on Linux.

@Mark6O9
Copy link
Author

Mark6O9 commented May 31, 2024

Images for proof:

Video Link:
video link
2024-05-31_13 15 18

Image Link:
image link
2024-05-31_13 16 30

@Mark6O9
Copy link
Author

Mark6O9 commented May 31, 2024

Log from Prism Launcher:

message.txt

@Mark6O9
Copy link
Author

Mark6O9 commented May 31, 2024

VLC is Installed
VLC Is installed

@SrRapero720
Copy link
Member

SrRapero720 commented May 31, 2024

you installed VLC via flatpak or Pakman?
sadly if was the case i can't give you support

consider use apt instead, because flatpak have a sandbox filesystem that doesn't let other things be readed.

@SrRapero720 SrRapero720 transferred this issue from SrRapero720/waterframes May 31, 2024
@SrRapero720
Copy link
Member

i transfered the issue to WATERMeDIA because the issue is for that lib

@SrRapero720 SrRapero720 added Bug: API Something isn't working Severity: Issue Modloader: Forge Type: Bug Type bug Status: Concerning This issue pulls me to different levels of concern Game: Minecraft labels May 31, 2024
@Mark6O9
Copy link
Author

Mark6O9 commented May 31, 2024

you installed VLC via flatpak or Pakman? sadly if was the case i can't give you support

consider use apt instead, because flatpak have a sandbox filesystem that doesn't let other things be readed.

I installed it via flatpak

@Jaskowicz1
Copy link

you installed VLC via flatpak or Pakman? sadly if was the case i can't give you support

consider use apt instead, because flatpak have a sandbox filesystem that doesn't let other things be readed.

Can confirm, this issue occurs with apt anyways. I'm on Debian 12 latest with VLC installed via apt and I still cannot view videos.

@Jaskowicz1
Copy link

Jaskowicz1 commented Jun 4, 2024

you installed VLC via flatpak or Pakman? sadly if was the case i can't give you support

consider use apt instead, because flatpak have a sandbox filesystem that doesn't let other things be readed.

Another thing, this isn't true! Flatpak just runs applications in a sandbox environment to protect users. Whilst the files still persist on your drive and can be accessed (for example, atlauncher via Flatpak is located at /home/.var/app/com.atlauncher.ATLauncher/), Flatpak ensures applications don't have every permission under the sun and can nuke everything. However, Watermedia knows of flatpak (as shown in the DIRECTORIES variable) so that isn't the issue here!

The issue (i assume from looking at the other directories) is because Watermedia isn't looking inside the vlc directory in x64_64-linux-gnu at https://github.com/SrRapero720/watermedia/blob/4cd8a933990a5dbbc4d2d80d5f2483e96c5811d4/lib-vlcj/src/main/java/uk/co/caprica/vlcj/discovery/provider/LinuxWellKnownDirectoryProvider.java#L31

Adding the directory: /usr/lib/x86_64-linux-gnu/vlc should fix this I believe!

@Jaskowicz1
Copy link

Actually, i'll just PR this myself to test that this is right.

@Jaskowicz1
Copy link

Jaskowicz1 commented Jun 4, 2024

So, I was wrong. Upon further inspection, it turns out that, not only is listFiles() unreliable (see https://github.com/SrRapero720/watermedia/blob/4cd8a933990a5dbbc4d2d80d5f2483e96c5811d4/lib-vlcj/src/main/java/uk/co/caprica/vlcj/discovery/strategy/BaseNativeDiscoveryStrategy.java#L120 and https://stackoverflow.com/questions/28984430/file-listfiles-does-not-work-on-linux), but, your for loop in the find function (https://github.com/SrRapero720/watermedia/blob/4cd8a933990a5dbbc4d2d80d5f2483e96c5811d4/lib-vlcj/src/main/java/uk/co/caprica/vlcj/discovery/strategy/BaseNativeDiscoveryStrategy.java#L118) simply doesn't finish!

Pulling your 2.0.x branch and changing the find function to be:

private String find(String directoryName) {
        try(DirectoryStream<Path> rootFolder = Files.newDirectoryStream(getSymLinkPathOrSelf(Paths.get(directoryName)).toPath())) {
            if (rootFolder == null) {
                File rootFile = new File(directoryName);
                LOGGER.debug(IT, "Cannot search on '{}', exists: {} - isDirectory: {} - canRead: {} - canExecute: {} ", directoryName, rootFile.exists(), rootFile.isDirectory(), rootFile.canRead(), rootFile.canExecute());
                return null;
            }

            LOGGER.info(IT, "Searching EPIC FILE on '{}'", directoryName);

            Set<String> matches = new HashSet<>(patternsToMatch.length);
            for (Path mainFile : rootFolder) {
                System.out.println("File name: " + mainFile.getFileName().toString());

                if (Files.isDirectory(mainFile)) continue;
                // check files directly
                for (Pattern pattern : patternsToMatch) {
                    System.out.println("Pattern to match: " + pattern.pattern());
                    Matcher matcher = pattern.matcher(mainFile.getFileName().toString());
                    if (matcher.matches()) {
                        System.out.println("Matches!");
                        // A match was found for this pattern (note that it may be possible to match multiple times, any
                        // one of those matches will do so a Set is used to ignore duplicates)
                        matches.add(pattern.pattern());
                        if (matches.size() == patternsToMatch.length) {
                            return directoryName;
                        }
                    }
                }
            }

            System.out.println("Looped successfully!");
        } catch (Exception ignored) {
            System.out.println("EXCEPTION!!");
        }

        return null;
    }

Sees the Looped successfully! never fire when looping through /usr/lib/x86_64-linux-gnu!

[04/06/2024 19:52:51 pm] [modloading-worker-0/INFO] Searching on '/usr/lib/x86_64-linux-gnu'
[04/06/2024 19:52:51 pm] File name: libpipewire-0.3.so.0
[04/06/2024 19:52:51 pm] File is libvlc.so.5? false
[04/06/2024 19:52:51 pm] Pattern to match: libvlc\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] Pattern to match: libvlccore\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] File name: libxml2.so.2
[04/06/2024 19:52:51 pm] File is libvlc.so.5? false
[04/06/2024 19:52:51 pm] Pattern to match: libvlc\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] Pattern to match: libvlccore\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] File name: libgstvideo-1.0.so.0
[04/06/2024 19:52:51 pm] File is libvlc.so.5? false
[04/06/2024 19:52:51 pm] Pattern to match: libvlc\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] Pattern to match: libvlccore\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] File name: libGLdispatch.so.0.0.0
[04/06/2024 19:52:51 pm] File is libvlc.so.5? false
[04/06/2024 19:52:51 pm] Pattern to match: libvlc\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] Pattern to match: libvlccore\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] File name: libGLX.so.0.0.0
[04/06/2024 19:52:51 pm] File is libvlc.so.5? false
[04/06/2024 19:52:51 pm] Pattern to match: libvlc\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] Pattern to match: libvlccore\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] File name: libgettextpo.so.0.5.9
[04/06/2024 19:52:51 pm] File is libvlc.so.5? false
[04/06/2024 19:52:51 pm] Pattern to match: libvlc\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] Pattern to match: libvlccore\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] File name: libgeoclue-2.so.0.0.0
[04/06/2024 19:52:51 pm] File is libvlc.so.5? false
[04/06/2024 19:52:51 pm] Pattern to match: libvlc\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] Pattern to match: libvlccore\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] File name: libcrypt.so.2
[04/06/2024 19:52:51 pm] File is libvlc.so.5? false
[04/06/2024 19:52:51 pm] Pattern to match: libvlc\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] Pattern to match: libvlccore\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] File name: libXt.so.6
[04/06/2024 19:52:51 pm] File is libvlc.so.5? false
[04/06/2024 19:52:51 pm] Pattern to match: libvlc\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] Pattern to match: libvlccore\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] File name: libSDL2-2.0.so.0.2800.5
[04/06/2024 19:52:51 pm] File is libvlc.so.5? false
[04/06/2024 19:52:51 pm] Pattern to match: libvlc\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] Pattern to match: libvlccore\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] File name: libmythes-1.2.so.0
[04/06/2024 19:52:51 pm] File is libvlc.so.5? false
[04/06/2024 19:52:51 pm] Pattern to match: libvlc\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] Pattern to match: libvlccore\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] File name: libquadmath.so.0.0.0
[04/06/2024 19:52:51 pm] File is libvlc.so.5? false
[04/06/2024 19:52:51 pm] Pattern to match: libvlc\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] Pattern to match: libvlccore\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] File name: libvorbisenc.so.2.0.12
[04/06/2024 19:52:51 pm] File is libvlc.so.5? false
[04/06/2024 19:52:51 pm] Pattern to match: libvlc\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] Pattern to match: libvlccore\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] File name: libxkbfile.so.1
[04/06/2024 19:52:51 pm] File is libvlc.so.5? false
[04/06/2024 19:52:51 pm] Pattern to match: libvlc\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] Pattern to match: libvlccore\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] File name: libnss_files.so.2
[04/06/2024 19:52:51 pm] File is libvlc.so.5? false
[04/06/2024 19:52:51 pm] Pattern to match: libvlc\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] Pattern to match: libvlccore\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] File name: libsystemd.so.0.37.0
[04/06/2024 19:52:51 pm] File is libvlc.so.5? false
[04/06/2024 19:52:51 pm] Pattern to match: libvlc\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] Pattern to match: libvlccore\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] File name: libunwind-setjmp.so.0
[04/06/2024 19:52:51 pm] File is libvlc.so.5? false
[04/06/2024 19:52:51 pm] Pattern to match: libvlc\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] Pattern to match: libvlccore\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] File name: libavcodec.so.60
[04/06/2024 19:52:51 pm] File is libvlc.so.5? false
[04/06/2024 19:52:51 pm] Pattern to match: libvlc\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] Pattern to match: libvlccore\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] File name: libanl.so.1
[04/06/2024 19:52:51 pm] File is libvlc.so.5? false
[04/06/2024 19:52:51 pm] Pattern to match: libvlc\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] Pattern to match: libvlccore\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] File name: libpixman-1.so.0.42.2
[04/06/2024 19:52:51 pm] Pattern to match: libvlc\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] File name: dvb-format-convert
[04/06/2024 19:52:51 pm] File is libvlc.so.5? false
[04/06/2024 19:52:51 pm] Pattern to match: libvlc\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] Pattern to match: libvlccore\.so(?:\.\d)*
[04/06/2024 19:52:51 pm] File is libvlc.so.5? false
[04/06/2024 19:52:51 pm] File is libvlc.so.5? false
[04/06/2024 19:52:51 pm] WOAHHHHHH LINUX TIME!!

For more context, WOAHHHHHH LINUX TIME!! is fired when LinuxNativeDiscoveryStrategy is asked if its supported. You can also ignore the [04/06/2024 19:52:51 pm] File is libvlc.so.5? false as this log came from a second test where I actually saved the log, I just added that in-case it wasn't logging everything.

It seems like the for loop is being cutoff by something (forge preventing this from taking too long?) so Watermedia is unable to find the VLC file.

Taking the code into a standalone project:

public static Pattern[] patternsToMatch;

    public static void main(String[] args) {
        patternsToMatch = new Pattern[1];
        patternsToMatch[0] = Pattern.compile("libvlc\\.so(?:\\.\\d)*");

        try(DirectoryStream<Path> rootFolder = Files.newDirectoryStream(getSymLinkPathOrSelf(Paths.get("/usr/lib/x86_64-linux-gnu")).toPath())) {
            for (Path mainFile : rootFolder) {
                System.out.println("File name: " + mainFile.getFileName().toString());

                if (Files.isDirectory(mainFile)) continue;

                for (Pattern pattern : patternsToMatch) {
                    System.out.println("Pattern to match: " + pattern.pattern());
                    Matcher matcher = pattern.matcher(mainFile.getFileName().toString());
                    if (matcher.matches()) {
                        System.out.println("Matches!");
                    }
                }
            }
        } catch (Exception ignored) {
        }
    }

    private static File getSymLinkPathOrSelf(Path path) {
        if (!Files.isSymbolicLink(path)) return path.toFile();
        try {
            File symLink = Files.readSymbolicLink(path).toFile();
            return symLink;
        } catch (Exception ignored) {}
        return path.toFile();
    }

I can see it finds the file correctly and shows "Matches!"

File name: libvlc.so.5
Pattern to match: libvlc\.so(?:\.\d)*
Matches!

I would heavily suggest you find out why in your own time for your next version. For now, I'm going to add a PR that will try see if VLC exists in specific files and use that, allowing this as a backup (that will most likely fail).

@Jaskowicz1
Copy link

God this has been a nightmare, anyways, I've figured it out without needing a PR!

Turns out, if you use ATLauncher via flatpak it doesn't see VLC files (should of guessed that before all this testing huh). In other words, @Mark6O9, make sure your ATLauncher isn't installed via Flatpak otherwise you won't be able to see Videos!

Going forward, @SrRapero720, you should add a notice to your README that states this mod does NOT work with any minecraft launcher/instance from Flatpak.

Hope this helps!

@SrRapero720
Copy link
Member

SrRapero720 commented Jun 4, 2024

Sees the Looped successfully! never fire when looping through /usr/lib/x86_64-linux-gnu!

Thats because when the SET is done (all are matched) the for loop is interrumped by the return block inside of the Matches check
in your second piece of code, you added the "matches" logger, so that explains why doesn't looks like "loop was finished"

It seems like the for loop is being cutoff by something (forge preventing this from taking too long?) so Watermedia is unable to find the VLC file.

If forge or neoforge do that they probably will be totally avoided for modding, because that will lead in a tons of crashes. Forge bootstrapping is offthread, so isn't affecting any modloading process for other mods

Turns out, if you use ATLauncher via flatpak it doesn't see VLC files (should of guessed that before all this testing huh). In other words, @Mark6O9, make sure your ATLauncher isn't installed via Flatpak otherwise you won't be able to see Videos!

No matters even if you install Minecraft out Flatpak, you cannot open VLC files if are managed by the flatpak FileSystem
Flatpack FS hides all theirs files for the OS FileSystem, even Flatpak installed stuff cannot see other Flatpak installed stuff.

Going forward, @SrRapero720, you should add a notice to your README that states this mod does NOT work with any minecraft launcher/instance from Flatpak.

I was forgetting about do that for a long time. i'll make sure i add it on readme (or wiki)

@SrRapero720 SrRapero720 changed the title Playing videos doesn't work on Linux Cannot load VLC installed via Flatpak Jun 7, 2024
@SrRapero720
Copy link
Member

For future references, VLC cannot be loaded if was installed via Flatpak, neither if launcher/minecraft was installed via Flatpak
Both have to be installed using other package managers (like APT-GET)

No, i cannot give support due to flatpak FileSystem limitations. PRs for workarrounds are welcome but i have no plans to support a sandboxed installation

@SrRapero720 SrRapero720 pinned this issue Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: API Something isn't working Game: Minecraft Modloader: Forge Severity: Issue Status: Concerning This issue pulls me to different levels of concern Type: Bug Type bug
Projects
None yet
Development

No branches or pull requests

3 participants