• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Android Grids and android..why??!!

kupo15

Member
Two things:

1. How is this an error? 0,0 is within 2,0

upload_2019-12-5_10-5-13.png

2. Why does this error not appear in the debug console during windows testing? Is there something different about android devices that I'm not aware of????
 

kupo15

Member
Every possible index is out of bounds when your grid has a height of 0.

Also, this error crops up in Windows F5 runs too, you just aren't paying attention.
Yeah you are right, I realized the height of 0 was the problem shortly afterwards. I feel slightly dumb but also not? I actually was paying attention to the console and it did not pop up on windows...until it did lol I did not realize that force quitting android does not trigger the game end event thus it was never saving a setting. Things were working perfectly seemingly perfectly on windows, just very strange, I had to do some special actions to replicate the issue on windows

This makes me wonder, why does GM allow a height of 0 at all? I respect GM not hand holding you that much but if you do something stupid like I did and set the grid height to 0 it should just crash. I mean, I guess some tricky dev might want to purposely set the width or height to 0 as a special way to flag grids that aren't used

Now I know better...thanks!
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Yeah you are right, I realized the height of 0 was the problem shortly afterwards. I feel slightly dumb but also not? I actually was paying attention to the console and it did not pop up on windows...until it did lol I did not realize that force quitting android does not trigger the game end event thus it was never saving a setting. Things were working perfectly seemingly perfectly on windows, just very strange, I had to do some special actions to replicate the issue on windows
Android (and iOS) are different to windows in that the user can exit the app or push it into the background in an instant (and they are designed that way), which means that it is impossible for GM to catch this and trigger an event. As for the grid error, iirc, this is actually being fixed so that any out of bounds errors will crash the runner on all platforms (it currently only crashes on HTML5 I think), so errors like this should be easier to debug.
 

kupo15

Member
Android (and iOS) are different to windows in that the user can exit the app or push it into the background in an instant (and they are designed that way), which means that it is impossible for GM to catch this and trigger an event. As for the grid error, iirc, this is actually being fixed so that any out of bounds errors will crash the runner on all platforms (it currently only crashes on HTML5 I think), so errors like this should be easier to debug.
Excellent looking forward to that, its well overdue! I don't have the html export so currently I can't get that hard crash.

Does the app lose focus when its pushed in the back? Is that a way to be able to trigger an event or line of code?
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Does the app lose focus when its pushed in the back? Is that a way to be able to trigger an event or line of code?
Nope...it's instantaneous and can't be captured by the app (or at least, it's not captured by any GameMaker apps). This is why things like os_is_paused() only trigger when the app is brought to foreground again and not when it's pushed to the background.
 

rIKmAN

Member
Excellent looking forward to that, its well overdue! I don't have the html export so currently I can't get that hard crash.

Does the app lose focus when its pushed in the back? Is that a way to be able to trigger an event or line of code?
If the app is closed on mobile you can use os_is_paused() to run any code before the app loses focus.

edit: ninja'd

@Nocturne
That's a bit ambiguous as the docs state that the code is run before the app is paused, but won't be acted upon until the app is reopened in the case of the example code using instance_create().

From the docs I would assume that setting variables etc would change them before the app was paused.
 
Last edited:

Nocturne

Friendly Tyrant
Forum Staff
Admin
That's a bit ambiguous as the docs state that the code is run before the app is paused, but won't be acted upon until the app is reopened in the case of the example code.
Hmmm... good point! I may be misremembering the docs, or it may be that it's being misrepresented in the docs. I'll check with the core tech devs tomorrow and see. :)
 

rIKmAN

Member
Hmmm... good point! I may be misremembering the docs, or it may be that it's being misrepresented in the docs. I'll check with the core tech devs tomorrow and see. :)
I haven't tested that function in a while, but as I remember it things like creating instances, layers etc won't be created until the next step (when the app regains focus) but any code that runs instantly like changing variables, arrays, lists etc would be done before the app was paused and ready to use once the app regained focus.

edit: Thinking about it, the above must be true as otherwise you wouldn't be able to store the time when the app was closed and compare it against the time when the app was re-opened and then simulate any changes in your game based off the amount of time it had been closed.

it also doesn't make sense that it's called os_is_paused() and only returns true and runs when the app is no longer paused lol, but that seems more like a bad naming choice than not running as intended.
 
Last edited:
C

Carcophan

Guest
As for the grid error, iirc, this is actually being fixed so that any out of bounds errors will crash the runner on all platforms (it currently only crashes on HTML5 I think), so errors like this should be easier to debug.
REALLY REALLY? This would be amazing!

I am actually having this very issue right now. I even, moments ago - posted an issue on it and happened to continue my search for a resolution and found this new thread! Not to derail the overall thread, as my issue has nothing to do with this one, but your sentence there made me lose it :D

Windows works, HTML5 crashes. I spent TWO WEEKS trying to figure out why without knowing that I had to check a CHROME developers tab to get an error message that was not present in GMS.
 

kupo15

Member
Android (and iOS) are different to windows in that the user can exit the app or push it into the background in an instant (and they are designed that way), which means that it is impossible for GM to catch this and trigger an event. As for the grid error, iirc, this is actually being fixed so that any out of bounds errors will crash the runner on all platforms (it currently only crashes on HTML5 I think), so errors like this should be easier to debug.
I hate to sound like a flip flopper on the subject but I kinda...KINDA...understand why having a width or height being 0 is kinda a good thing. It makes looping and filling in things much easier. For example:

This was my last app I recently did. I had to check if there was any useful data in the grid before adding to it otherwise I would have the first row blank and entry data would start on row 2
Code:
/// in create I did: season_ranking_grid  = ds_grid_create(width,1); // to give one row in there

var ranking_hh = ds_grid_height(season_ranking_grid); // height of ranking
if season_ranking_grid[# 0,0] == undefined
        ranking_hh --;
      
        // add column
        ds_grid_resize(season_ranking_grid,ds_grid_width(season_ranking_grid),ranking_hh+1); // add to end of grid
        ds_grid_resize(season_ranking_usage_grid,ds_grid_width(season_ranking_grid),ranking_hh+1); // add to end of usage grid
However for the one I'm working on now, I decided to create the grid with no rows and it made adding to it much easier and doesn't require the check

Code:
/// create: grid = ds_grid(width,0); // no rows

var grid_ww = ds_grid_width(grid);
var grid_hh = ds_grid_height(grid);

ds_grid_resize(grid,grid_ww,grid_hh+1);
          
            // add data
            grid[# 0,grid_hh+1 ] = name; // add name to first column
            grid[# 1,grid_hh+1] = itemlist; // add itemlist grid id to second column
So having grids have a row/col of 0 is a good thing and should be kept. However, I still think that a hard crash when accessing out of bounds in the grid should happen instead of silently failing.
 
Top