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

Improve overflow handling / CLAY_MAX_ELEMENT_COUNT exceeded #52

Merged
merged 13 commits into from
Dec 1, 2024

Conversation

nicbarker
Copy link
Owner

This PR greatly improves the story around capacity overflows in various internal data structures.

Currently there are still some unsolved (but not unsolvable) problems:

  • Text will not be rendered if CLAY_MEASURE_TEXT_CACHE_SIZE is exceeded.
  • The error screen for exceeding CLAY_MAX_ELEMENT_COUNT is quite severe and non configurable:
Screenshot 2024-11-30 at 7 42 52 pm

@nicbarker nicbarker merged commit b8725bf into main Dec 1, 2024
3 checks passed
@bullno1
Copy link
Contributor

bullno1 commented Dec 1, 2024

What about user-provided hook that defaults to assert/debugbreak?

Although tbh, if you reach that point, there's not much the program can do.

What does Clay do in that case though? Does it stop rendering new elements or just stop rendering altogether?

@nicbarker
Copy link
Owner Author

@bullno1 Yeah it's a tricky situation, because if Clay runs out of allocated memory, we obviously don't want to just outright crash, and we certainly don't want memory corruption, but at the same time the exhaustion is almost always going to happen half way through a layout declaration, which means the user is going to keep calling clay functions (potentially hundreds or thousands of times) after we've run out of memory.

At the moment it just refuses to render and emits one render command with that warning message saying "run out of capacity", and I'm going to follow up with a PR that allows you to switch that off so it never happens even if you run out of memory in production.

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

Successfully merging this pull request may close these issues.

2 participants