Destroying tiles physics memory [concept abandoned]

Get help using Construct 2

Post » Sun Jul 10, 2016 1:14 pm

I have run into a bit of an unexpected problem with the physics and tilemap plugins. I am clearing out tiles in a tilemap that also has the physics immovable behaviour. Sometimes this causes the following error to be displayed:

Image

This seems to happen when I clear a large number of tiles in relatively quick succession (3 per second for 10 secs seems to cause it to happen). Creating a bug report will be rather challenging... Anyone any ideas what might cause this and how to avoid it?

Thanks.
Last edited by Colludium on Mon Jul 11, 2016 5:43 am, edited 1 time in total.
A big fan of JavaScript.
B
74
S
20
G
71
Posts: 2,229
Reputation: 44,890

Post » Sun Jul 10, 2016 4:32 pm

Update - using the Chrome console I note the following extra info:

Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 33554432, (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.

Physics_behavior.js:10 Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 33554432, (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.
A big fan of JavaScript.
B
74
S
20
G
71
Posts: 2,229
Reputation: 44,890

Post » Sun Jul 10, 2016 6:46 pm

There is this bug here that has a similar issue:
viewtopic.php?f=152&t=106159&p=786541&hilit=TOTAL_MEMORY+physics#p786541
I didn't find others but I recall there being some reported elsewhere. That particular one had no response but the fix as I recall was the behavior was updated with a bigger TOTAL_MEMORY, which just delays the error till more memory is used.

If it helps the non-asm.js version of box2d doesn't have this issue, and you can change it in the project properties.

Best I understand it is asm.js requires the amount of memory needed to be reserved beforehand, and it can't change. Based on ashley's last blog, webassembly would be an improvement on asm.js in that it lets the amount of memory needed to change while the program runs.

Anyway things like changing animation frame, changing size, or adding/removing tiles on the tilemap all cause the physics objects to be updated and I guess that fills up the memory with asm.js?
B
92
S
32
G
109
Posts: 5,294
Reputation: 70,999

Post » Sun Jul 10, 2016 7:06 pm

Thanks @R0J0hound - that looks like a very similar bug. I was not able to reproduce this on a simple capx, of course; I guess my original setup was the bigger memory case... :/.

However, I -think- I might have fixed the problem....

I tried box2d, but it made no difference; I created a physics-only tilemap (so bitwise updates were excluded from potentially causing a collision polygon problem), but neither of those fixed it.... I was also able to simultaneously destroy 400 tiles (with bitwise updates) but that would not replicate the problem.

In the end (and I think it's now negated) I created an event log system to ensure that each tile can only be called to erase once per tick. There was a potential failure where the multiplayer peer calls could have caused tiles to be called to be erased on subsequent ticks. So far, so good... :)

Cheers.
A big fan of JavaScript.
B
74
S
20
G
71
Posts: 2,229
Reputation: 44,890

Post » Mon Jul 11, 2016 5:42 am

Final update. So far not so good... The only fix for this appears to be to reduce the size of the tilemap. So, since the game cannot be effectively shrunk that way I've decided to abandon using the default physics for falling objects. It appears that dynamically updating a large-ish tilemap is not possible in c2. In isolation I couldn't reproduce this, which is frustrating, so it might only be a factor with large event numbers.

With physics removed this problem does not occur.
A big fan of JavaScript.
B
74
S
20
G
71
Posts: 2,229
Reputation: 44,890


Return to How do I....?

Who is online

Users browsing this forum: Blendi1223, gskunk, richcoz81, tarek2, Wartexnik and 48 guests