[BUG] Cocos Creator 3.4 GameCanvas element has hard-coded dimensions

After upgrading to 3.4 the window dimensions for the Desktop Web builds no longer respect the settings specific in Build Settings.


Additionally even if I hard code the dimensions in the template they are overriden at runtime.


Thank you. I will ask engineering to have a look.

Hi, my test was normal.
If you are using a custom project build template, this will prevail.

The dimensions are correct in the build output, i.e. the index.html file.
However if you open the developer console in the browser the dimensions are being set dynamically and are not respecting the aspect ratio set in the build config.

This is not a bug, the current design is the way it is.
The values in the build panel are used to modify the GameDiv.
If you need to be able to set up the Cocos3dGameContainer manually yourself, you will need to customize the engine yourself.
File path:340engine\engine\pal\screen-adapter\web\screen-adapter.ts

It seems the solution we are looking for involves setting "exactFitScreen": true in the settings json file. Is there a checkbox for that somewhere?

Does that mean in order to have my game maintain a fixed aspect ratio of 16:9 I would have to modify the engine? Or is there a setting I am missing somewhere?


Do you mean that the GameCanvas size is not the same as the GameDiv?
The actual values are the same, or you can try this:
cc.screen.windowSize = new Size(width, height)

According to an old post here: CocosCreator 跨平台全屏适配方案整理 - Creator 2.x - Cocos中文社区 you can get Exact Fit by this
Here we expand the ExactFit (check Fit Height, Fit Width) mode at the same time.
Which no longer appears to work in 3.4 because my output in settings.json is
"designResolution":{"width":1280,"height":720,"policy":2},"platform":"web-desktop","exactFitScreen":false,

I think we figured out how to make this work, but need to know how to enable exactFitScreen in the settings.json file. I don’t see a place to switch that from false to true in the project settings.

We did not find any anomalies. Please give us the screen where the anomalies appeared and tell us what is the expected correct effect?

Please tell me how to enable exactFitScreen in the settings.json file, other than manually editing the file. Is there a way? I don’t think there are any issues to fix other than this. We’re changing the way we were doing things and need this boolean set to true in the settings.json file. Please tell me how to enable exactFitScreen in the settings.json file that gets built with a build. Please. Please. Please. Thank you. :smiley:

I tested with version 3.4.1, and the exactFitScreen in settings.json was true after each of my builds

The engine team has received this bug and they are working on the issue, which is expected to be resolved in version 3.4.2.

1 Like

Got some feedback from the engine team, it is a custom build template setup problem, in 3.4 engine team updated a bit of how custom build template define and works, so the older setup file might perform differently.

Now if you want the view window to be full screen and resize with the window, you should use the web-mobile platform for building, for web- desktop platform it assumes the view is only a part of the window and wont resize with it.