Skip to content

Remove CanvasParentResizePlugin#11057

Merged
alice-i-cecile merged 1 commit intobevyengine:mainfrom
ThierryBerger:winit_029-remove_web_resize
Dec 21, 2023
Merged

Remove CanvasParentResizePlugin#11057
alice-i-cecile merged 1 commit intobevyengine:mainfrom
ThierryBerger:winit_029-remove_web_resize

Conversation

@ThierryBerger
Copy link
Copy Markdown
Member

@ThierryBerger ThierryBerger commented Dec 21, 2023

Improves #11052

Changelog

  • Remove Window::fit_canvas_to_parent, as its resizing on wasm now respects its CSS configuration.

Migration Guide

  • Remove uses of Window::fit_canvas_to_parent in favor of CSS properties, for example:
    canvas {
      width: 100%;
      height: 100%;
    }

@ThierryBerger ThierryBerger added the A-Windowing Platform-agnostic interface layer to run your app in label Dec 21, 2023
@alice-i-cecile
Copy link
Copy Markdown
Member

You appear to be missing an issue link :)

@alice-i-cecile alice-i-cecile added C-Examples An addition or correction to our examples C-Code-Quality A section of code that is hard to understand or change labels Dec 21, 2023
@alice-i-cecile alice-i-cecile added this to the 0.13 milestone Dec 21, 2023
@ThierryBerger ThierryBerger mentioned this pull request Dec 21, 2023
23 tasks
@rparrett rparrett added the M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide label Dec 21, 2023
@github-actions
Copy link
Copy Markdown
Contributor

It looks like your PR is a breaking change, but you didn't provide a migration guide.

Could you add some context on what users should update when this change get released in a new version of Bevy?
It will be used to help writing the migration guide for the version. Putting it after a ## Migration Guide will help it get automatically picked up by our tooling.

Copy link
Copy Markdown
Contributor

@tim-blackbird tim-blackbird left a comment

Choose a reason for hiding this comment

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

When the website gets updated for the 0.13 release we can revert bevyengine/bevy-website#640.

@MeoMix
Copy link
Copy Markdown

MeoMix commented Dec 21, 2023

Really excited for this! :) I think this will make it simpler to avoid a flicker due to incorrect sizing on first load of my WASM app!

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Dec 21, 2023
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Dec 21, 2023
Merged via the queue into bevyengine:main with commit 80f15e0 Dec 21, 2023
@cshenton-work
Copy link
Copy Markdown

A migration guide would be appreciated.

fit_canvas_to_parent provided the exact behaviour I was depending on, simply giving me a full screen canvas that scaled with the window, without the need for any external css/html other than the default generated by most wasm runners.

@daxpedda
Copy link
Copy Markdown
Contributor

daxpedda commented Jan 5, 2024

@cshenton-work I've noted what needs to be done in #11052 (comment):

Window::fit_canvas_to_parent was still useful to apply the CSS width: 100%; height: 100%, something similar should be introduced again (without all the resizing stuff, it should literally only apply these CSS values).

So until this is hopefully addressed in Bevy, just get the canvas and apply width: 100%; height: 100% to it's style attribute.

EDIT: I can actually see that the commit has added a migration guide: 80f15e0. I assume this will be later compiled into the changelog.

ThierryBerger added a commit to ThierryBerger/bevy that referenced this pull request Jan 9, 2024
Implemented suggestions from reviewers: a simpler fit_canvas_to_parent
leads to an explicit CSS setting to the canvas.

It has do be set after wgpu creation due to wgpu overriding the canvas width/height:
https://github.com/gfx-rs/wgpu/blob/4400a5847080d1164bdca93a90622414963ed9f3/examples/src/utils.rs#L68-L74
ThierryBerger added a commit to ThierryBerger/bevy that referenced this pull request Jan 9, 2024
Implemented suggestions from reviewers: a simpler fit_canvas_to_parent
leads to an explicit CSS setting to the canvas.

It has do be set after wgpu creation due to wgpu overriding the canvas width/height:
https://github.com/gfx-rs/wgpu/blob/4400a5847080d1164bdca93a90622414963ed9f3/examples/src/utils.rs#L68-L74
@frewsxcv
Copy link
Copy Markdown
Contributor

The CSS replacement of fit_canvas_to_parent does not work for me. Doesn't seem to resize like it used to https://rgis.app

@MeoMix
Copy link
Copy Markdown

MeoMix commented Feb 23, 2024

The CSS replacement of fit_canvas_to_parent does not work for me. Doesn't seem to resize like it used to https://rgis.app

Your width/height 100% isn't taking precedent over other stylings set programmatically.

image

@frewsxcv
Copy link
Copy Markdown
Contributor

@MeoMix To my knowledge, I am not setting them programmatically in my project

@frewsxcv
Copy link
Copy Markdown
Contributor

1280 x 720 is coming from Bevy:

physical_width: 1280,
physical_height: 720,

@frewsxcv
Copy link
Copy Markdown
Contributor

@MeoMix
Copy link
Copy Markdown

MeoMix commented Feb 23, 2024

Understood.

#11278 It sort of looks like this PR wanted to get merged in but didn't make it?

@ThierryBerger
Copy link
Copy Markdown
Member Author

In the meantime I believe a workaround has been to set the width/height of the container div/html

@frewsxcv
Copy link
Copy Markdown
Contributor

In the meantime I believe a workaround has been to set the width/height of the container div/html

Set it to what?

@ThierryBerger
Copy link
Copy Markdown
Member Author

To 100%. (Or the size you want your inner canvas to be)

ThierryBerger added a commit to ThierryBerger/bevy that referenced this pull request Mar 3, 2024
Implemented suggestions from reviewers: a simpler fit_canvas_to_parent
leads to an explicit CSS setting to the canvas.

It has do be set after wgpu creation due to wgpu overriding the canvas width/height:
https://github.com/gfx-rs/wgpu/blob/4400a5847080d1164bdca93a90622414963ed9f3/examples/src/utils.rs#L68-L74
github-merge-queue bot pushed a commit that referenced this pull request Mar 3, 2024
Follow up to #11057

Implemented suggestions from reviewers from: a simpler
fit_canvas_to_parent leads to an explicit CSS setting to the canvas.

From my understanding, it has do be set after wgpu creation due to wgpu
overriding the canvas width/height:
https://github.com/gfx-rs/wgpu/blob/4400a5847080d1164bdca93a90622414963ed9f3/examples/src/utils.rs#L68-L74


# Changelog

- Re-enable a `fit_canvas_to_parent`, it's removal from
#11057 was problematic. Still,
its inner working is more simple than before: bevy doesn't handle its
resizing, winit does.

## Migration Guide

- Cancels the migration from
#11057
spectria-limina pushed a commit to spectria-limina/bevy that referenced this pull request Mar 9, 2024
Follow up to bevyengine#11057

Implemented suggestions from reviewers from: a simpler
fit_canvas_to_parent leads to an explicit CSS setting to the canvas.

From my understanding, it has do be set after wgpu creation due to wgpu
overriding the canvas width/height:
https://github.com/gfx-rs/wgpu/blob/4400a5847080d1164bdca93a90622414963ed9f3/examples/src/utils.rs#L68-L74


# Changelog

- Re-enable a `fit_canvas_to_parent`, it's removal from
bevyengine#11057 was problematic. Still,
its inner working is more simple than before: bevy doesn't handle its
resizing, winit does.

## Migration Guide

- Cancels the migration from
bevyengine#11057
v-kat pushed a commit to v-kat/bevy that referenced this pull request Mar 17, 2024
Follow up to bevyengine#11057

Implemented suggestions from reviewers from: a simpler
fit_canvas_to_parent leads to an explicit CSS setting to the canvas.

From my understanding, it has do be set after wgpu creation due to wgpu
overriding the canvas width/height:
https://github.com/gfx-rs/wgpu/blob/4400a5847080d1164bdca93a90622414963ed9f3/examples/src/utils.rs#L68-L74


# Changelog

- Re-enable a `fit_canvas_to_parent`, it's removal from
bevyengine#11057 was problematic. Still,
its inner working is more simple than before: bevy doesn't handle its
resizing, winit does.

## Migration Guide

- Cancels the migration from
bevyengine#11057
v-kat pushed a commit to v-kat/bevy that referenced this pull request Mar 21, 2024
Follow up to bevyengine#11057

Implemented suggestions from reviewers from: a simpler
fit_canvas_to_parent leads to an explicit CSS setting to the canvas.

From my understanding, it has do be set after wgpu creation due to wgpu
overriding the canvas width/height:
https://github.com/gfx-rs/wgpu/blob/4400a5847080d1164bdca93a90622414963ed9f3/examples/src/utils.rs#L68-L74


# Changelog

- Re-enable a `fit_canvas_to_parent`, it's removal from
bevyengine#11057 was problematic. Still,
its inner working is more simple than before: bevy doesn't handle its
resizing, winit does.

## Migration Guide

- Cancels the migration from
bevyengine#11057
v-kat pushed a commit to v-kat/bevy that referenced this pull request Apr 26, 2024
Follow up to bevyengine#11057

Implemented suggestions from reviewers from: a simpler
fit_canvas_to_parent leads to an explicit CSS setting to the canvas.

From my understanding, it has do be set after wgpu creation due to wgpu
overriding the canvas width/height:
https://github.com/gfx-rs/wgpu/blob/4400a5847080d1164bdca93a90622414963ed9f3/examples/src/utils.rs#L68-L74


# Changelog

- Re-enable a `fit_canvas_to_parent`, it's removal from
bevyengine#11057 was problematic. Still,
its inner working is more simple than before: bevy doesn't handle its
resizing, winit does.

## Migration Guide

- Cancels the migration from
bevyengine#11057
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Windowing Platform-agnostic interface layer to run your app in C-Code-Quality A section of code that is hard to understand or change C-Examples An addition or correction to our examples M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants