collision_line_list crashes the game after short time

Tornado

Member
Hi!

Last week I migrated my project to GMS2.
In my game I used 3 collision_line to check if one instance (the ball) will collide with 3 different objects.
But then I saw a new function collision_line_list in GMS2. So I thought I could just use one collision_line_list instead and then check the list for collisions with all objects of interest.

I have now this code in the step event of an object:
Code:
collision_line_list(ballCollisionLine1_x, ballCollisionLine1_y, ballCollisionLine1_x2, ballCollisionLine1_y2, all, false, true, global.ballCollisionLine1List, false);
...
...do some checkings on the list...
...
ds_list_clear(global.ballCollisionLine1List);
When I run the game with this code, the game crashes like within 5-30 seconds.
I put some output into console and I see there that every step the list always contains 2-9 instances. So, it shouldn't be a problem.

Is there something I'm doing wrong here or this new function has a bug?

This happens when running on Windows-Platform. I couldn't check right now if it happens on Android, because at the moment I have some problems building apk.

I'm using IDE v2.2.1.375 Runtime v2.2.1.287
Thx
 
Last edited:
You've probably already done this(because I see your list is global, so I assume you are just creating it once at the start of the game), but just double-check you're not re-creating the list every step using ds_list_create().

ds_list_clear() clears the list, but doesn't destroy the data structure.
 

Tornado

Member
I forgot to describe how the game crashes: It freezes for 1-2 seconds and then the game window just disappears!
 
Have you tried running the game in debug mode and observing what happens in the profiler and the instance list?

Is the memory increasing rapidly? Is there some unexpected instances being created over and over etc?
 
P

ph101

Guest
Perhaps it is something to do with the line you are checking. Where are your x1,y1,x2,y2 variables coming from. Can you output them as debug? does it happen if they remain static? Just some suggested lines of enquiry.

You also mentioned 3 collision lines but only show code for 1. At what stage do the others happen.

Another point - what is the code you are checking the list with? Maybe its something there? Also is there any error? I guess not which is indeed ominous, also is it YYC or VM?

edit. (I know you probably have thought of all these but just ideas :) )
 
Last edited by a moderator:

Tornado

Member
I removed all code for checking. Now I have only this:
Code:
collision_line_list(global.ballCollisionLine1_x, global.ballCollisionLine1_y, global.ballCollisionLine1_x2, global.ballCollisionLine1_y2, all, false, true, global.ballCollisionLine1List, false);
ds_list_clear(global.ballCollisionLine1List);
The problem still occurs.

x and y values are fine. In my "old" code I use them in the function collision_line and also for debugging purposes I can draw the lines on the screen, they are 100% ok.
3 collision lines I have in my old code and I use there collision_line (not collision_line_list). I needed 3 lines because i want to check if the ball possibly will collide with 3 different objects (let's say obj1, obj2 and obj3).
(I cannot make one parent of those three objects because they already have their own parent hierarchie for another purpose)

So, I thought I can optimize this by replacing 3 collision_line by 1 collision_line_list. I then just check in the list with which objects the line collides.

I'm trying now to use the profiler...never used it before...
So far in Windows Task-Manager the process looks stable - no memory or CPU increase.

I tested now on more platforms:
- Windows WM: crash
- Windows YYC: crash
- Android VM: crash
- Android YYC: OK

I also tried with fix coordinates:
collision_line_list(100,100,700,700, all, false, true, global.ballCollisionLine1List, false);
Still the same problem happens. (the room is 720x1200)

This is in the console when I run on Windows VM and after the game dissapears:
Code:
X://windows/Runner.exe exited with non-zero status (-1073741819)
elapsed time 00:00:50.3114234s for command "C:\ProgramData/GameMakerStudio2/Cache/runtimes\runtime-2.2.1.287/bin/Igor.exe" -options="C:\Users\Zoran\AppData\Local\GameMakerStudio2\GMS2TEMP\build.bff"  -- Windows Run started at 12/15/2018 13:07:02
"cmd"  /c subst Z: /d

elapsed time 00:00:00.0448661s for command "cmd" /c subst Z: /d started at 12/15/2018 13:07:52
"cmd"  /c subst Y: /d

elapsed time 00:00:00.0507820s for command "cmd" /c subst Y: /d started at 12/15/2018 13:07:52
"cmd"  /c subst X: /d

elapsed time 00:00:00.0464348s for command "cmd" /c subst X: /d started at 12/15/2018 13:07:52
FAILED: Run Program Complete
We plan to release our game soon, we have tons of other things to do...I'll invest 3-4 hours in research, if it fails, I'll just go back to collision_line and try to optimize another way. I won't risk it with collision_line_list then.

Thx for your help.[/CODE]
 
Last edited:
P

ph101

Guest
I guess you dont want to waste much time on it but you could try destroying and creating the list instead to see if it continues. It does seem to be a bug in the function perhaps.. I read elsewhere on the forum someone having an issue with this function on permament objects. May or may not be related. I hope you get a chance to file the bug so it can be fixed in future versions! :D
 

Tornado

Member
I guess you dont want to waste much time on it but you could try destroying and creating the list instead to see if it continues. It does seem to be a bug in the function perhaps.. I read elsewhere on the forum someone having an issue with this function on permament objects. May or may not be related. I hope you get a chance to file the bug so it can be fixed in future versions! :D
That crashes as well :-(
Code:
var dummyList = ds_list_create();
collision_line_list(100,100,700,700, all, false, true, dummyList, false);
ds_list_destroy(dummyList);
 
P

ph101

Guest
Tbh it would be good to see the code you are using to look at this list it could be something there - what if you comment that out but leave the above?
edit. or is that literally all you have and it crashes? Does it happen in a seperate project?
 

Tornado

Member
Tbh it would be good to see the code you are using to look at this list it could be something there - what if you comment that out but leave the above?
edit. or is that literally all you have and it crashes? Does it happen in a seperate project?
I already removed the code which checks the list. It is now really only those three lines regarding the list!

I only have one project. If I'll have time, maybe I'll make small test project.
 
Last edited:

Tornado

Member
I made a small project. I put a collision_line_list and created many moving objects (3 types of objects) on the screen. First no collision was detected at all. For this I had to define an empty collision event in all 3 objects.
Then I ran it again and it was fine. Even with 10,000 objects! Everything was fine.
Then it occured to me to remove a collision event from one object. I restarted again and the problem happend!
I didn't notice it right away. Only after putting enough objects on the screen, the problem was there.
Apparently this is some weird constellation, when it will happen!
 
Last edited:

Tornado

Member
instead of
collision_line_list(xx1,yy1,xx2,yy2, all, false, true, collisionList, false);
I also tried collision_line
collision_line(xx1,yy1,xx2,yy2, all, false, true);

and that crashes too if some object doesnt have collision event!!!

I'm beginning to think that the keyword "all" is the trouble maker!!!
So it seems in my project when I switched from collision_line to using collision_line_list, the problem is that now I use keyword "all" and before with collision_line I didn't udes that keyword but I used three separate collision_line's with explicit objects.
 

GMWolf

aka fel666
hmmm, ever since YYG added spacial acceleration structures Collisions have been a little buggy.
my guess is that if an object has no collision events it will not be considered the same way when its added to the spacial acceleration structure and that causes problems when sing the explicit collision functions like collision_line?

anyhow, that really does sound like a bug. you should file a report.
 

Tornado

Member
I'll try to file a report.
Weird thing is in the sample project, that it doesn't happen when I have let's say under 200 moving objects even though for example obj3 doesn't have collision event. Only when I increase the number of objects then it happens!
It is unpredictable...sometimes for example with 400 objects it crashes immediately, sometimes not.

Thank you all for your time!!!
 
Last edited:
P

ph101

Guest
Looks like it could be due to this? Check the runtime release notes http://gms.yoyogames.com/release-notes-runtime.html

  • Smaller collision tree - only instances that have collision events or are marked as solid are added by default. Others are added if a collision query is made that would/could return them
  • Note: If any collision call is made with "object_all" everything gets added to the tree, so it is best to avoid doing this
The variation you are seeing does still sound like a bug, you can file it from within GM2 using help > report a bug takes 5 minutes and means it could get fixed down the line ;)
 
Top