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

Crash when using non-preloaded material #4498

Closed
LeXXik opened this issue Aug 2, 2022 · 5 comments
Closed

Crash when using non-preloaded material #4498

LeXXik opened this issue Aug 2, 2022 · 5 comments
Labels

Comments

@LeXXik
Copy link
Contributor

LeXXik commented Aug 2, 2022

When a render component is changing to a material that was not preloaded, the application crashes.

Repro: https://playcanvas.com/project/965390/overview/material-issue

  1. Click a mouse to change the cube material.
  2. App will crash.

Repro in 1.54.1 and 1.53.4.

There is no crash, if the changed material is set to preload.

@yaustar yaustar added bug area: graphics Graphics related issue area: assets labels Aug 2, 2022
@kungfooman
Copy link
Collaborator

So when you const red = this.red.resource; and the asset is not loaded, you receive undefined and then you set undefined to type Material?

I don't think that is right in the first place and a clear type error, what should happen otherwise? Maybe preallocate a StandardMaterial and assign it to Asset#resource, that is then "updated" later by Asset, once its loaded?

@slimbuck
Copy link
Member

slimbuck commented Aug 3, 2022

Yep, you'd have to get the red material asset and 'load' it as usual. Once that's complete, asset.resource should be valid and you can set it on the render component.

Perhaps we can also issue a debug message when render.material isn't set cc @mvaligursky ?

@LeXXik
Copy link
Contributor Author

LeXXik commented Aug 3, 2022

Yes, I understand the reasoning and the cause. Currently the crash is cryptic and hard to debug, especially in multi-user projects.

@yaustar
Copy link
Contributor

yaustar commented Aug 3, 2022

Yeah, the error message is pretty far from the code that's causing it from the user point of view:
image

@mvaligursky
Copy link
Contributor

Debug warning added in #4524.
Closing this ticket, as there is no other issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants