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

Objects fall slower in production compared to development mode #1315

Open
annalytic opened this issue Sep 4, 2024 · 5 comments
Open

Objects fall slower in production compared to development mode #1315

annalytic opened this issue Sep 4, 2024 · 5 comments

Comments

@annalytic
Copy link

annalytic commented Sep 4, 2024

I'm using matter-js 0.19.0 and use vite to build the game.
I notice that the gravity is much lower / objects fall a lot slower in production compared to when developing locally.
The game is hosted on github pages.

Anyone have any idea why?

@photonstorm
Copy link

There's nothing in the Matter code that distinguishes between production / local (indeed, I'm not sure how you'd even do this accurately). I would start by doing some simple logging - console.log the gravity value at keys points and compare prod/dev - maybe the build/minification process is messing a config somewhere. Also, check the fps rate (enable dev tools fps monitor) - is it stable and the same between prod and dev?

@ggorlen
Copy link

ggorlen commented Sep 7, 2024

Can you share the code?

@annalytic
Copy link
Author

annalytic commented Sep 9, 2024

Can you share the code?

You can see the game live here: https://bekk.github.io/javazone-spill/
(It is made for resolution 528x704)
You will see the soda cans fall very slowly. They're supposed to fall faster. The movement of the hand seems to go in the same velocity in dev/local version and built version, but the cans fall slower in built version.

Btw I noticed the error is in the built version of the project. If I build the project and run it on preview server the soda boxes fall slowly.

The codebase is huge, I can't share all that. Is there anything specific you'd like to see, then I can share that.

@ggorlen
Copy link

ggorlen commented Sep 9, 2024

Thanks. The build is minified which makes it hard to debug. If the source code is huge, I suggest creating a minimal failing example--remove the unnecessary parts so it's easier to focus on the core problem. Without some source code it's very difficult to help--things like this are usually use case specific and not something someone might happen to know off the top of their head. As photonstorm said, there's no difference between prod and dev as far as MJS is concerned.

@annalytic
Copy link
Author

annalytic commented Sep 18, 2024

Thanks. The build is minified which makes it hard to debug. If the source code is huge, I suggest creating a minimal failing example--remove the unnecessary parts so it's easier to focus on the core problem. Without some source code it's very difficult to help--things like this are usually use case specific and not something someone might happen to know off the top of their head. As photonstorm said, there's no difference between prod and dev as far as MJS is concerned.

Here is a minimal version of the app we have running. The two most important files are GameCanvas.tsx and useSodaBoxAnimation.ts

https://github.com/annalytic/matter-js

This is how the physics are when running the
Local version:
https://github.com/user-attachments/assets/60cbef65-e741-492a-8245-4b711f89c584

Built version:
https://github.com/user-attachments/assets/82f5a770-5a90-4b05-971b-fa5c32275bc0

You can easily see the boxes fall slower in the built version of the app.

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

No branches or pull requests

3 participants