Physics world buffer full, world could not be created

We are loading levels and different game screens with collection proxies in our game. The loaded collection is then also loading child collections through collection factories. When a screen is replaced by another, the collection proxy for that screen is unloaded.
So the general setup is:

  • World screen where a world is selected (gui only)
    • Level select screen where the level is selected (full game setup - gui, tilemaps, sprites)
      • Level (full game setup)

Every time a level is finished, the player is back on level select. This works without problems and new levels can be selected and played, but if I go back to the world screen and select a new world, the engine crashes with “Physics world buffer full, world could not be created.”.

Obviously something is still loaded in the engine preventing it from loading new content, but as far as I can see the fault is not at our end. Is there a good way to debug this?

2 Likes

The message is not great at describing what is actually going on - the buffers for holding worlds (= collection proxies) have been exceeded. I’m guessing that the new collection you loaded in turn contains one or more collection proxies (i.e. your game uses nested collection proxies)? The buffer size can be configured in game.project under collection_proxy > max_count. Try to increase that number and the error should go away.

Thank you, but that actually wasn’t it. Regardless of how high i set the collection_proxy max_count the game still crashed.
The problem was a cut scene that was loaded but never enabled for some levels. The unloading was made in the cut scene script and since it was never enabled it was never unloaded. Why this caused a crash - I don’t know.

1 Like

I had this problem myself and thought I would write up my findings if someone else googles the problem.

Short answer

My problem was that I needed to increase the “world_count” in the project file. This is the amount of physics worlds you can have active in your game.

A bit longer

From a Slack discussion

A world is where the physics objects live for a collection. Each physics world has its own objects. Objects cannot interact between worlds.

Every new collection you load with a collection proxy will be a new top level collection, and they will get a physics world.

You can read a bit more here: http://www.defold.com/manuals/collection-proxies/#_worlds

A question for the Engine team is then:
Doesn’t that mean that [collection_proxy] max_count and [physics] world_count should be the same?

7 Likes

No, the collection proxy max count is the max number of proxy components that exist in the running game. The world count is the max number of loaded collections (by proxy).

(EDIT: Correction below)

If I understand that correct then one is the max how many exists as components over all your files and one are the one is the max that are actually loaded?

I was a bit wrong in my description. This is how it works:

proxy > max_count is the limit to the number of collection proxy components you can have in a loaded collection (i.e. world). You can have unlimited number of components in your project files.

physics > world_count is the number of loaded physics worlds, i.e. collections loaded via a collection proxy component.

So, for instance:

proxy > max_count = 8
physics > world_count = 4

  • main.collection contains 8 collection proxy components. Each is a proxy to a separate collection file (“one.collection”, “two.collection” etc) that each contains 8 collection proxy components.
  • All in all we have 64 components, which is fine. We can even start sending “load” messages to all these proxies:
  • one: loaded ok
  • two: loaded ok
  • three: loaded ok
  • four: oops… ERROR:PHYSICS: Physics world buffer full, world could not be created (main plus three additional worlds loaded)
3 Likes

If I understand it correct then (and my testing also supports that) it works like this:

Number of “collection_instances” that can exist at the same time, i.e. collections added from file.

[collection]
max_instances = 1024

Number of collection proxies that can be loaded at the same time, i.e. collections loaded from a proxy.

[collection_proxy]
max_count = 16

Number of physics worlds that can be loaded at the same time.

[physics]
world_count = 4

But then if adding a collection proxy always creates a new physics world then if you physics world count is 4 and your collection proxy max 16. It is impossible to hit the max ceiling of the your collection proxy max and get ERROR:GAMESYS: Collection proxy could not be created since the buffer is full (4), tweak "collection_proxy.max_count" in the config file. because you will get ERROR:PHYSICS: Physics world buffer full, world could not be created before that.

Is this a correct observation? What I am getting at is that: Isn’t one of world_count and max_count redundant?

1 Like

No. The world count is the number of loaded collections through proxy. If you add a proxy component to your main collection, nothing happens. To make the proxy load its collection and create a new world you need to send it a “load” message. That is when world_count matters.

1 Like

This is incorrect. This number governs the max number of proxy components in a world.

It is important to be able to separate these. Say that you have a very large game world and want to allow the player to move without loading through it, then you could have chunks of world in separate collections with an exit point to the north, south, east and west.

At any given point you probably want to have the current chunk loaded as well as the ones to the north, south, east and west. That means that you have to have world_count set to 5.

On the other hand, you want to have proxies somewhere for all existing chunks. One way is to have a central loader with a large number of proxy components. Then you set proxy max_count to the number of chunks you have and make sure you never have more than 5 worlds loaded at the same time.

Or in a Candy-style game you might want 1000 proxy components in the main collection but only load one additional world at a time, i.e proxy max_count = 1000 and world_count = 2.

1 Like