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

Launch game from the backend when processing launch protocol without sending a message to the frontend #4188

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

arielj
Copy link
Collaborator

@arielj arielj commented Dec 20, 2024

We've always had a weird/complicated flow to start a game when using the heroic://launch protocol: main.ts would call the handleProtocol function, that would eventually call sendFrontendMessage, then the frontend would receive a message to launch the given game and that will trigger another call to the backend to then be handled by ipcMain.on('launch', ...)

We can avoid all that extra work by calling the launch code directly from the backend.

I used this opportunity to extract the logic of the launch handler and put it into launcher.ts where it makes more sense, that helps removing imports and code from main.ts that is already too big and complicated.

The launchEventCallback function is just the code from main.ts as a function, there's nothing to review in there cause it's literally the same code.

This should speed things a biiiiiit when launching games with the protocol, but I doubt is significant.

<--- Put the description here --->


Use the following Checklist if you have changed something on the Backend or Frontend:

  • Tested the feature and it's working on a current and clean install.
  • Tested the main App features and they are still working on a current and clean install. (Login, Install, Play, Uninstall, Move games, etc.)
  • Created / Updated Tests (If necessary)
  • Created / Updated documentation (If necessary)

@arielj arielj changed the title Emit the launch ipcMain event instead of sending the launchGame message to the frontend when launching with protocol Launch game from the backend when processing launch protocol without sending a message to the frontend Dec 20, 2024
@arielj arielj marked this pull request as ready for review December 20, 2024 05:42
@arielj arielj requested review from a team, flavioislima, CommandMC, Nocccer and imLinguin and removed request for a team December 20, 2024 05:42
@arielj arielj added the pr:ready-for-review Feature-complete, ready for the grind! :P label Dec 20, 2024
@CommandMC
Copy link
Collaborator

The round trip actually had a reason: Prompting the user to update the game in case there is an update. It doesn't seem like this is happening now?

@arielj
Copy link
Collaborator Author

arielj commented Dec 20, 2024

The round trip actually had a reason: Prompting the user to update the game in case there is an update. It doesn't seem like this is happening now?

The launch flow when using the protocol seems to always try to launch the game as if there were no updates, check this https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/blob/main/src/frontend/state/GlobalState.tsx#L793 it has hasUpdate: false hardcoded.

It doesn't have the same logic to ask about updates that we have when clicking the play button.

@Etaash-mathamsetty
Copy link
Member

Etaash-mathamsetty commented Dec 20, 2024

The round trip actually had a reason: Prompting the user to update the game in case there is an update. It doesn't seem like this is happening now?

The launch flow when using the protocol seems to always try to launch the game as if there were no updates, check this main/src/frontend/state/GlobalState.tsx#L793 it has hasUpdate: false hardcoded.

It doesn't have the same logic to ask about updates that we have when clicking the play button.

I think I had a fix for this somewhere, I don't know what I did with it lol. I guess as an alternative, we can run it in offline mode if there are updates available

@arielj
Copy link
Collaborator Author

arielj commented Dec 20, 2024

Maybe that can be a different PR? this one is just to not go to the frontend, currently we don't handle updates in that flow so this would keep the same behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:ready-for-review Feature-complete, ready for the grind! :P
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants