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

web: Automatically chosen preferred renderer #10831

Conversation

iwannabethedev
Copy link
Contributor

web: Add 'Automatic' option to 'preferredRenderer'.

The 'Automatic' option is with this PR the default. The option lets Ruffle select the renderer.

This option is more or less the same as similar options in related technologies have, with one example being Phaser 3:

https://newdocs.phaser.io/docs/3.55.2/Phaser.Types.Core.GameConfig

phaser_preferred_renderer

This PR came about through discussion and investigation between @n0samu and me and others.

The changes have been lightly tested manually.

@iwannabethedev
Copy link
Contributor Author

This PR uses a commit from #10829 , so this PR will probably have to be rebased once that PR is merged or closed without merging.

@iwannabethedev
Copy link
Contributor Author

n0samu and I have added an extra check.

@@ -383,8 +388,9 @@ export interface BaseLoadOptions {
* falling back to more basic backends if necessary.
* The available values in order of default preference are:
* "webgpu", "wgpu-webgl", "webgl", "canvas".
* If the renderer is set to RenderBackend.Automatic or "", Ruffle selects the renderer.
Copy link
Member

Choose a reason for hiding this comment

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

This is already explained by the existing comments, so not really needed IMO

@iwannabethedev iwannabethedev force-pushed the automatic_preferred_renderer branch 2 times, most recently from 2da90f0 to 1b49510 Compare April 26, 2023 22:34
@iwannabethedev iwannabethedev marked this pull request as ready for review April 26, 2023 22:35
@iwannabethedev iwannabethedev force-pushed the automatic_preferred_renderer branch 2 times, most recently from c923764 to 10c406b Compare April 26, 2023 23:36
@iwannabethedev iwannabethedev force-pushed the automatic_preferred_renderer branch from 10c406b to f4609d4 Compare April 27, 2023 00:00
@n0samu
Copy link
Member

n0samu commented Apr 27, 2023

Let's hold off on merging this until we can decide if this is really the best approach

@relrelb
Copy link
Contributor

relrelb commented Apr 27, 2023

As far as I understand, preferredRenderer: null and preferredRenderer: RenderBackend.Automatic are totally equivalent. Also, with forceRenderer in mind, I think forceRenderer: RenderBackend.Automatic doesn't make sense (and neither { preferredRenderer: RenderBackend.Automatic, forceRenderer: true }), so I'm not sure adding RenderBackend.Automatic is the way to go.

Ideally, we could remain with just preferredRenderer: null, but I'm not sure how it's best to implement in options.ts...

@iwannabethedev
Copy link
Contributor Author

As far as I understand, preferredRenderer: null and preferredRenderer: RenderBackend.Automatic are totally equivalent.

Yes, 100% correct.

Also, with forceRenderer in mind, I think forceRenderer: RenderBackend.Automatic doesn't make sense (and neither { preferredRenderer: RenderBackend.Automatic, forceRenderer: true }), so I'm not sure adding RenderBackend.Automatic is the way to go.

In hindsight, this option might have been better of me to have implemented after the other parts of the options had been figured out. But it is not much work, and the work here can be used to help figure out what future work on this should be, so it is alright.

Ideally, we could remain with just preferredRenderer: null, but I'm not sure how it's best to implement in options.ts...

I actually implemented a version that supported null and force-pushed it (disappearing some non-null-using approach), but then I reversed course and decided against supporting null, and force-pushing these changes made the null-using changes disappear. I should probably have saved the changes in a side-branch 😅 . I think I did it by changing class SelectOption implements OptionElement<string> to class SelectOption implements OptionElement<string | null> and change the implementation accordingly.

The reason why I decided against it and reversed course was that all the other export const enum types in 'load-options.ts' do not allow null, and I tend to like "narrowing" types when possible. I also wrote some stuff in the Discord, I think in the #rendering channel (and maybe also some in #meta-discussion before we moved the discussion to #rendering ).

But it can be done with null, since I did test it and made it work and force-pushed it, from what I remember.

@iwannabethedev
Copy link
Contributor Author

Wait, I think it was in #frontends-apps , not #rendering .

@relrelb
Copy link
Contributor

relrelb commented Apr 27, 2023

I actually implemented a version that supported null and force-pushed it (disappearing some non-null-using approach), but then I reversed course and decided against supporting null, and force-pushing these changes made the null-using changes disappear. I should probably have saved the changes in a side-branch 😅 . I think I did it by changing class SelectOption implements OptionElement<string> to class SelectOption implements OptionElement<string | null> and change the implementation accordingly.

I changed SelectOption to imeplement OptionElement<string | null> in #10835, so it can be usable here once merged.

@n0samu
Copy link
Member

n0samu commented Apr 30, 2023

Once #10835 is merged, we can change this PR to just be this single-line change, right?
image

If so, let's plan to do that. Thanks!

@iwannabethedev
Copy link
Contributor Author

@n0samu I have read through both of the PRs again, and I agree, I believe that would work correctly, and I also believe it would be a very nice way of doing it. I will wait until the other PR is merged, and then update and test and rebase and then force-push a commit for this PR making it a one-line change in a single commit.

@relrelb
Copy link
Contributor

relrelb commented May 2, 2023

@iwannabethedev Given that merging #10835 (if at all) will probably take some time, maybe the common.ts changes should be included in this PR, in order to unblock it. Then only the <option value="">Automatic</option> addition will be needed like you described.

@iwannabethedev
Copy link
Contributor Author

@iwannabethedev Given that merging #10835 (if at all) will probably take some time, maybe the common.ts changes should be included in this PR, in order to unblock it. Then only the <option value="">Automatic</option> addition will be needed like you described.

I believe that the PR in #10900 already includes those changes to common.ts . I believe that it might make sense to get #10900 merged (maybe after extracting and removing the changes with enableFallbackRenderers like Dinnerbone proposed), since it also additionally has translations.

@iwannabethedev
Copy link
Contributor Author

Superseded by #10900 .

@iwannabethedev iwannabethedev deleted the automatic_preferred_renderer branch May 6, 2023 12:33
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

Successfully merging this pull request may close these issues.

3 participants