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

Feature/java downloader #2069

Open
wants to merge 81 commits into
base: develop
Choose a base branch
from

Conversation

Trial97
Copy link
Member

@Trial97 Trial97 commented Jan 25, 2024

blocked by this meta PR:PrismLauncher/meta#19
partially supersedes: #285 (I only focused on automatic java switch and download)
For testing the Metadata pointer should point towards: https://raw.githubusercontent.com/Trial97/prism-meta-launcher/split_java_source/
Have something working but still ignore this until is converted from draft, for a progress report check the ToDo list:
This should work now. I'm now in the process of testing it with Asan.
To do:

timoreo22 and others added 30 commits October 24, 2022 08:02
Signed-off-by: timoreo <contact@timoreo.fr>
Signed-off-by: timoreo <contact@timoreo.fr>
Signed-off-by: timoreo <contact@timoreo.fr>
Signed-off-by: timoreo <contact@timoreo.fr>
Signed-off-by: timoreo <contact@timoreo.fr>
Signed-off-by: timoreo <contact@timoreo.fr>
Signed-off-by: timoreo <contact@timoreo.fr>
Signed-off-by: timoreo <contact@timoreo.fr>
Signed-off-by: timoreo <contact@timoreo.fr>
Signed-off-by: timoreo <contact@timoreo.fr>
Signed-off-by: timoreo <contact@timoreo.fr>
Signed-off-by: timoreo <contact@timoreo.fr>
Signed-off-by: timoreo <contact@timoreo.fr>
Delete LaunchContext

Signed-off-by: timoreo <contact@timoreo.fr>
Signed-off-by: timoreo <contact@timoreo.fr>
Co-authored-by: DioEgizio <83089242+DioEgizio@users.noreply.github.com>
Signed-off-by: timoreo <contact@timoreo.fr>
Signed-off-by: timoreo <contact@timoreo.fr>
Co-authored-by: flow <flowlnlnln@gmail.com>
Signed-off-by: timoreo <contact@timoreo.fr>
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
…nloader

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
 into feature/java-downloader

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Copy link
Contributor

@ColonelGerdauf ColonelGerdauf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In context of the UI side of this PR; it is needed as it significantly simplifies the setup of instances.
Especially so when people have a pre-1.17 instance and a post-1.16.5 instance.

It will be painful to set up the defaults for one Java version, but then be forced to manually enter version path and arguments for each incompatible instance.

@DioEgizio
Copy link
Member

DioEgizio commented May 8, 2024

is it really necessary to have to download things like java-runtime-alpha and java-runtime-beta? I think just downloading java-runtime-gamma in 1.17 and 1.18 is fine. Also does the java autodownload work on archs where mojang doesn't provide everything (arm macs where there's only gamma and delta, linux arm64/arm32 where mojang provides no jres, and i guess arm windows)? Because if i understood correctly this only works for java runtimes from Mojang

@Trial97
Copy link
Member Author

Trial97 commented May 8, 2024

Mostly yes as mojang decided that the Minecraft is for that version.
It is a bit harder to map it to other java versions and I would still prefer if we go with what mojang serves for that Minecraft version instead of our own mappings for the autodownload even if there aren't versions for all possible architecture.
If that fails we can give the excuse that Microsoft doesn't support that architecture.
And in worst case if it is really needed we can do that change in meta on a later date.

@DioEgizio
Copy link
Member

I don't think this solution is that great then. Providing a good experience to those on arm is important, and installing useless JREs isn't that great

@Trial97
Copy link
Member Author

Trial97 commented May 9, 2024

Ok I will look into it then :)
If mojang doesn't provide java for the lesser-known Minecraft versions I will map it to either 8 or 17 is that ok?
This change will be done in the meta side of this PR so there will be no code change on this PR.

@Trial97
Copy link
Member Author

Trial97 commented May 9, 2024

@DioEgizio I mapped the alpha and beta to the gamma version on arm os(mac and windows). As mentioned I opted only to change the arm ones because they do not have an alternative and I want to keep it as close to what mojang uses. If the user doesn't want to use what we provide they can override the java path with one already installed on the system.

If the mojang provides no jres for that mc version the auto download fails, but the auto select should still work. And as of now jre-legacy(aka java 8) on arm is not provided, should we link it against adoptium for that?

@DioEgizio
Copy link
Member

@DioEgizio I mapped the alpha and beta to the gamma version on arm os(mac and windows). As mentioned I opted only to change the arm ones because they do not have an alternative and I want to keep it as close to what mojang uses. If the user doesn't want to use what we provide they can override the java path with one already installed on the system.

If the mojang provides no jres for that mc version the auto download fails, but the auto select should still work. And as of now jre-legacy(aka java 8) on arm is not provided, should we link it against adoptium for that?

Iirc there's no adoptium java jre 8 for macOS arm, so we should link azul there. Also how shouldn't we also link everything on Linux arm64 and arm32?

@Trial97
Copy link
Member Author

Trial97 commented May 10, 2024

Iirc there's no adoptium java jre 8 for macOS arm, so we should link azul there. Also how shouldn't we also link everything on Linux arm64 and arm32?

I will look into populating the java using azul for arm mac and window.
There is no version for linux arm, and if you mean that we should link the linuxx64 to linuxx86 also no( usually the x64 programs do not work on x86)

@DioEgizio
Copy link
Member

I mean we should link arm linux to adoptium

@Trial97
Copy link
Member Author

Trial97 commented May 10, 2024

I mean we should link arm linux to adoptium

I will also look into that, but all the mentioned changes are meta related not related to the code on this PR.
So can I get an approval here once I map all the mentioned versions?
PS. the meta can be updated even after this PR is merged: so now we should focus on determining if the current format is ok or not.

@Trial97
Copy link
Member Author

Trial97 commented May 10, 2024

@DioEgizio I updated the meta PR to take into account the arm stuff but be aware that even so there are still cases where there is no java that matches the major and the os (e.g. windows_arm doesn't have java 8 in any vendor).
But at least now linux_arm and macos_arm should be the best we can do for now( mapped the missing values to adoptium/azul)

@DioEgizio
Copy link
Member

the only thing i find kinda weird is still needing to have a global java. Why would I need it if i enable that feature, apart from that, LGTM

@Trial97
Copy link
Member Author

Trial97 commented May 11, 2024

The global java is used as a fallback in this case: if for what so reason the feature doesn't find a suitable java(there are a few rare cases the java doesn't exist for that arch) or if it fails to download it will fall back to global.
In the future, I want to split the global java into either java profiles or just a few java paths:
image

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
@TayouVR TayouVR requested a review from getchoo May 18, 2024 12:09
@lordofpipes
Copy link

lordofpipes commented May 20, 2024

This is breaking the build when -DENABLE_JAVA_DOWNLOADER is not turned on, when it's launched without any data.

Built with: Fedora 39, cmake -S . -B build -G Ninja -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Debug -DLauncher_QT_VERSION_MAJOR="5" && cmake --build build --config Debug && cmake --install build && cmake --install build --config Debug --component install

[Thread debugging using libthread_db enabled]                                                                                                                                                 
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7fffe4c006c0 (LWP 1181528)]                                                                                                                                                     
[New Thread 0x7fffdfe006c0 (LWP 1181529)]
Downloading separate debug info for /lib64/libGLX_nvidia.so.0                                                                                                                                 
Downloading separate debug info for /lib64/libnvidia-glsi.so.470.239.06                                                                                                                       
Downloading separate debug info for /lib64/libnvidia-tls.so.470.239.06                                                                                                                        
Downloading separate debug info for /lib64/libnvidia-glcore.so.470.239.06                                                                                                                     
     0.000 D | <> Log initialized.                                                                                                                                                            
     0.000 D | <> No migration needed from "PolyMC"
     0.000 D | <> No migration needed from "MultiMC"
     0.000 D | Prism Launcher, © 2022-2024 Prism Launcher Contributors, © 2021-2022 PolyMC Contributors, © 2012-2021 MultiMC Contributors
     0.000 D | Version                    :  "9.0-feature/java-downloader"
     0.000 D | Platform                   :  "unknown"
     0.000 D | Git commit                 :  "b23b53d98d5c99353a79355371a7eb7a8537df0c"
     0.000 D | Git refspec                :  "refs/heads/feature/java-downloader"
     0.000 D | Compiled for               :  "Linux 6.8.9-200.fc39.x86_64 x86_64"
     0.000 D | Compiled by                :  "GNU - 13.2.1"
     0.000 D | Build Artifact             :  ""
     0.000 D | Updates Enabled           :  No
     0.000 D | Work dir before adjustment :  "/home/lordpipe/repos/PrismLauncher/install"
     0.000 D | Work dir after adjustment  :  "/home/lordpipe/.local/share/PrismLauncher"
     0.000 D | Adjusted by                :  "Persistent data path"
     0.000 D | Binary path                :  "/home/lordpipe/repos/PrismLauncher/install/bin"
     0.000 D | Application root path      :  "/home/lordpipe/repos/PrismLauncher/install"
     0.000 D | <> Paths set.
     0.035 D | Detected default console font: "Noto Sans Mono" , substitutions: ""
     0.078 D | <> Settings loaded.
[New Thread 0x7fffdcc006c0 (LWP 1181531)]
     0.116 D | Detecting proxy settings...                                                                                                                                                    
     0.116 D | Using no proxy is an option!
     0.116 D | <> Network done.
     0.116 C | Exception: "Unable to open /home/lordpipe/.local/share/PrismLauncher/translations/index_v2.json for reading: No such file or directory"
     0.116 C | Translations Download Failed: index file not readable
     0.117 W | Selected invalid language "" , defaulting to "en_US"
     0.117 D | Your language is ""
     0.117 D | <> Translations loaded.
     0.117 D | Started watching  "/home/lordpipe/.local/share/PrismLauncher/icons"
     0.117 D | Sorting icon list...
     0.118 D | <> Instance icons intialized.
     0.118 D | [Theme] <> Initializing Icon Themes
     0.119 D | [Theme] Loaded Built-In Icon Theme "pe_colored"
     0.119 D | [Theme] Loaded Built-In Icon Theme "pe_light"
     0.119 D | [Theme] Loaded Built-In Icon Theme "pe_dark"
     0.119 D | [Theme] Loaded Built-In Icon Theme "pe_blue"
     0.119 D | [Theme] Loaded Built-In Icon Theme "breeze_light"
     0.119 D | [Theme] Loaded Built-In Icon Theme "breeze_dark"
     0.119 D | [Theme] Loaded Built-In Icon Theme "OSX"
     0.119 D | [Theme] Loaded Built-In Icon Theme "iOS"
     0.119 D | [Theme] Loaded Built-In Icon Theme "flat"
     0.119 D | [Theme] Loaded Built-In Icon Theme "flat_white"
     0.119 D | [Theme] Loaded Built-In Icon Theme "multimc"
     0.119 D | [Theme] Icon Theme Folder Path:  "/home/lordpipe/.local/share/PrismLauncher/iconthemes"
     0.119 D | [Theme] <> Icon themes initialized.
     0.119 D | [Theme] <> Initializing Widget Themes
     0.119 D | [Theme] Determining System Theme...
     0.120 D | [Theme] System theme seems to be: "breeze"
     0.120 D | [Theme] Considering theme from theme factory: "breeze"
     0.120 D | [Theme] System theme has been determined to be: "Breeze"
     0.120 D | [Theme] Loading Built-in Theme: "system"
     0.120 D | [Theme] Loading Built-in Theme: "dark"
     0.120 D | [Theme] Loading Built-in Theme: "bright"
     0.120 D | [Theme] Theme Folder Path:  "/home/lordpipe/.local/share/PrismLauncher/themes"
     0.120 D | [Theme] <> Widget themes initialized.
     0.120 D | [Theme] CatPacks Folder Path: "/home/lordpipe/.local/share/PrismLauncher/catpacks"
     0.907 D | Instance path              :  "instances"                                                                                                                                      
     0.907 D | Loading Instances...
     0.907 D | Discovering instances in "/home/lordpipe/.local/share/PrismLauncher/instances"
     0.907 D | <> Instances loaded.
     0.907 D | Loading accounts...
     0.907 C | "Failed to read the account list file (accounts.json)."
     0.907 D | <> Accounts loaded.
     0.908 D | <> Cache initialized.
     0.908 D | Downloading Translations Index...
     0.914 C | dlopen() failed: t file: cannot open shared object file: No such file or directory                                                                                             
     0.914 C | dlopen() failed: libopenal.so: cannot open shared object file: No such file or directory
     0.914 D | Detected native libraries: "" ""
     0.941 D | [Theme] <> Icon theme set.
     0.941 D | [Theme] applying theme "System"
     0.949 D | [Theme] <> Application theme set.

Thread 1 "prismlauncher" received signal SIGSEGV, Segmentation fault.
QAbstractButton::setText (this=0x0, text=...) at widgets/qabstractbutton.cpp:551
551	   Q_D(QAbstractButton);                                                                                                                                                             
(gdb) bt 40
#0  QAbstractButton::setText (this=0x0, text=...) at widgets/qabstractbutton.cpp:551
#1  0x00000000005ac17e in JavaSettingsWidget::retranslate (this=0x17d6860) at /home/lordpipe/repos/PrismLauncher/launcher/ui/widgets/JavaSettingsWidget.cpp:491
#2  0x00000000005a9659 in JavaSettingsWidget::setupUi (this=0x17d6860) at /home/lordpipe/repos/PrismLauncher/launcher/ui/widgets/JavaSettingsWidget.cpp:161
#3  0x00000000005a79be in JavaSettingsWidget::JavaSettingsWidget (this=0x17d6860, parent=0x1782510) at /home/lordpipe/repos/PrismLauncher/launcher/ui/widgets/JavaSettingsWidget.cpp:37
#4  0x00000000005083c2 in JavaWizardPage::setupUi (this=0x1782510) at /home/lordpipe/repos/PrismLauncher/launcher/ui/setupwizard/JavaWizardPage.cpp:34
#5  0x00000000005082a6 in JavaWizardPage::JavaWizardPage (this=0x1782510, parent=0x15a2960) at /home/lordpipe/repos/PrismLauncher/launcher/ui/setupwizard/JavaWizardPage.cpp:26
#6  0x0000000000499066 in Application::createSetupWizard (this=0x7fffffffc6b0) at /home/lordpipe/repos/PrismLauncher/launcher/Application.cpp:1100
#7  0x0000000000494888 in Application::Application (this=0x7fffffffc6b0, argc=@0x7fffffffc6ac: 1, argv=0x7fffffffc9a8) at /home/lordpipe/repos/PrismLauncher/launcher/Application.cpp:1050
#8  0x0000000000487c5c in main (argc=1, argv=0x7fffffffc9a8) at /home/lordpipe/repos/PrismLauncher/launcher/main.cpp:67
(gdb)

@lordofpipes
Copy link

Most of the version lists in PrismLauncher are sorted in descending order, but it seems these versions are not retaining any particular ordering. In this case, the correct version to select is the middle one, which should probably be elevated to the top based on date or semver sorting.
image

@lordofpipes
Copy link

lordofpipes commented May 20, 2024

Trying to figure out why instance overrides are not working. I have the following debugs:

diff --git a/launcher/minecraft/launch/AutoInstallJava.cpp b/launcher/minecraft/launch/AutoInstallJava.cpp
index 1dc91003f..a12881a2e 100644
--- a/launcher/minecraft/launch/AutoInstallJava.cpp
+++ b/launcher/minecraft/launch/AutoInstallJava.cpp
@@ -60,12 +60,17 @@ AutoInstallJava::AutoInstallJava(LaunchTask* parent)
 void AutoInstallJava::executeTask()
 {
     auto settings = m_instance->settings();
+    qDebug() << "OverrideJava: " << settings->get("OverrideJava");
+    qDebug() << "OverrideJavaLocation: " << settings->get("OverrideJavaLocation");
+    qDebug() << "JavaPath: " << settings->get("JavaPath");
     if (!APPLICATION->settings()->get("AutomaticJavaSwitch").toBool() ||
         (settings->get("OverrideJava").toBool() && settings->get("OverrideJavaLocation").toBool() &&
          QFileInfo::exists(settings->get("JavaPath").toString()))) {
+        qDebug() << "Returning";
         emitSucceeded();
         return;
     }
+    qDebug() << "Continuing";
     auto packProfile = m_instance->getPackProfile();
     if (!APPLICATION->settings()->get("AutomaticJavaDownload").toBool()) {
         auto javas = APPLICATION->javalist();

and an instance.cfg with: (in this example we are intentionally pulling in an incorrect Java version so we can distinguish the automatic swap that occurs at launch, but the same applies to anything)

IgnoreJavaCompatibility=true
OverrideJavaArgs=true
OverrideJavaLocation=true
JavaPath=/usr/lib/jvm/java-11-openjdk-11.0.23.0.9-1.fc39.x86_64/bin/java

but it gives:

   105.036 D | "1.20.4" : Finished asset index download
   105.090 D | OverrideJava:  QVariant(bool, false)
   105.091 D | OverrideJavaLocation:  QVariant(bool, true)
   105.091 D | JavaPath:  QVariant(QString, "/usr/lib/jvm/java-11-openjdk-11.0.23.0.9-1.fc39.x86_64/bin/java")
   105.091 D | Continuing

Is it normal for these to show up as false? I think something is preventing instance-specific Java overrides from working when global auto-detect is enabled, which is making auto-detect act as a confusing master override over the user's Java settings.

Edit: I think the problem is that sometimes instance.cfg will have nothing set for OverrideJava while still having a java override configured. I notice that CheckJava.cpp uses this method for checking whether an override is configured:

 bool perInstance = settings->get("OverrideJava").toBool() || settings->get("OverrideJavaLocation").toBool();

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
@Trial97
Copy link
Member Author

Trial97 commented May 20, 2024

fixed all the comments mentioned by lordofpipes

@lordofpipes
Copy link

lordofpipes commented May 20, 2024

The sorting still has this pathological case, since Mojang has re-used the version number:

image

Other issues seem to be fixed. Works really well!

@Trial97
Copy link
Member Author

Trial97 commented May 20, 2024

That is fine as both share the same number it doesn't matter if you manually install the first over the second in this case.

@lordofpipes
Copy link

Just confirmed they are exactly the same. I thought maybe they changed what modules are included, but nope, same files. Wonder why Mojang published it twice — maybe one of them served as a release candidate.

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Copy link

@lordofpipes lordofpipes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it a fair bit and it seems solid.

@Trial97
Copy link
Member Author

Trial97 commented May 21, 2024

@getchoo this is prio(and you already said you will review)
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Blocked until another PR is merged changelog:added A PR that appears under "Added" in the changelog enhancement New feature or request
Projects
None yet
10 participants