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

Switch to Canvas Rendering #857

Merged
merged 6 commits into from
Apr 28, 2024
Merged

Switch to Canvas Rendering #857

merged 6 commits into from
Apr 28, 2024

Conversation

CryZe
Copy link
Collaborator

@CryZe CryZe commented Apr 27, 2024

This switches the rendering of the layout from using HTML and CSS to using a canvas (technically it's two). This not only should improve the performance but also brings the rendering in line with our native renderers, enabling new features such as vertical resizing and horizontal layouts. This also removes a lot of code specific to the HTML rendering and thus greatly simplifies the codebase. There is one slight regression in that the layout editor doesn't allow clicking and dragging the individual components directly on the layout anymore. This is however something we can explore directly in livesplit-core in the future, so other frontends can benefit from it as well.

@CryZe CryZe added enhancement A new feature or general improvement to LiveSplit One. UI The issue is about the user interface. performance Performance is suboptimal and should be improved. layout rendering This affects the rendering of LiveSplit layouts. high priority This is a high priority issue. labels Apr 27, 2024
@CryZe CryZe requested a review from wooferzfg April 27, 2024 17:25
@CryZe CryZe force-pushed the canvas-renderer branch 4 times, most recently from cdf260d to 1b9916f Compare April 27, 2024 18:20
@wooferzfg
Copy link
Member

We probably don't need the rendering tests anymore, now that livesplit-core is handling it

@wooferzfg
Copy link
Member

I'll test out the changes in this PR later today and see if I notice any issues.

@CryZe
Copy link
Collaborator Author

CryZe commented Apr 27, 2024

It's still better to keep the tests I think, since that ensures the HTML canvas also behaves the way we expect it to, since that's not something lsc tests.

This switches the rendering of the layout from using HTML and CSS to
using a canvas (technically it's two). This not only should improve the
performance but also brings the rendering in line with our native
renderers, enabling new features such as vertical resizing and
horizontal layouts. This also removes a lot of code specific to the HTML
rendering and thus greatly simplifies the codebase. There is one slight
regression in that the layout editor doesn't allow clicking and dragging
the individual components directly on the layout anymore. This is
however something we can explore directly in `livesplit-core` in the
future, so other frontends can benefit from it as well.
@CryZe
Copy link
Collaborator Author

CryZe commented Apr 27, 2024

Alright the tests pass now. The only thing that I know that's still left to fix is the "mobile layout" where we use 100% width, but I forgot doing the same for the height... though it's more complicated there, because we also want the control buttons underneath, so like 100% - the height of the buttons. It's pretty late here, so if you want to fix that up, I'd appreciate that.

@CryZe CryZe marked this pull request as ready for review April 27, 2024 19:52
@wooferzfg
Copy link
Member

wooferzfg commented Apr 27, 2024

One thing that's not ideal right now is that layouts don't auto save. So if you change the layout direction but don't click save and then refresh, it remembers the size but not the direction, and ends up in a weird state
(It also doesn't prompt you when closing the page when you have an unsaved layout, like it does for unsaved splits)

chrome_b8PeHofiv0

@CryZe
Copy link
Collaborator Author

CryZe commented Apr 27, 2024

Yeah I noticed that too. I think that'll be resolved once we save the size in the layout itself, so it's probably something we can (should) live with for a bit.

@wooferzfg
Copy link
Member

Prompting for unsaved layout changes would be helpful, too. I think that'll need to be something built into livesplit-core?

@wooferzfg
Copy link
Member

The only thing that I know that's still left to fix is the "mobile layout" where we use 100% width, but I forgot doing the same for the height... though it's more complicated there, because we also want the control buttons underneath, so like 100% - the height of the buttons.

This logic makes sense for a vertical layout, but probably not for a horizontal layout. I think a horizontal layout shouldn't take up the entire height, and it should go off the edge of the screen if necessary (since it's hard to fit an entire horizontal layout into a narrow width)

@CryZe
Copy link
Collaborator Author

CryZe commented Apr 27, 2024

Yeah but you probably just don't want a horizontal layout on mobile anyway. But yeah filling the entire screen is probably not ideal always anyway. I think these can all be follow up issues.

This was causing the layout settings to not be interactable, since the resizing element was blocking them.
@wooferzfg
Copy link
Member

wooferzfg commented Apr 27, 2024

I pushed a change to auto adjust the layout height on mobile, only when the layout direction is vertical. (Feel free to squash my commits - I just don't like force pushes when it's not my PR.)

(The horizontal layout still doesn't work very well on mobile, because it requires a ton of horizontal scrolling and also makes the editor views super wide. But that's a problem to fix later.)

@CryZe
Copy link
Collaborator Author

CryZe commented Apr 28, 2024

I just don't like force pushes when it's not my PR.

No need, as long as the commits are clean(ish), they are totally fine.

@CryZe CryZe merged commit 1819925 into LiveSplit:master Apr 28, 2024
1 check passed
@CryZe CryZe deleted the canvas-renderer branch April 28, 2024 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature or general improvement to LiveSplit One. high priority This is a high priority issue. layout rendering This affects the rendering of LiveSplit layouts. performance Performance is suboptimal and should be improved. UI The issue is about the user interface.
Projects
None yet
2 participants