Simple Javascript function crashing app on (somewhat) older device

My app is moderately(?) complicated, with about 150 items on the screen at once. It performs okay, but is a little laggy on older devices (testing on a Samsung S8). I can live with the lagginess, but as soon as I add in a JS module with some simple math and string manipulation, the app starts crashing fairly often, especially if I send a lot of tap events quickly. I can tell it’s the JS causing this because if I take it out of the logic, it never crashes.

Are JS functions particularly slow in Appgyver? Or prone to instability? I’m just wondering how I can fix this because the function would be quite messy to convert to flow functions (if that would even help.) It seemed much cleaner to do that work in JS.

The screen where this is happening is shown below. Users tap in the four grids, and the app does calculations in the background. The JS function takes the coordinates from the grids and creates the labels you see below the grids (e.g. “1 out, 0.5 up”). The table at the bottom also gets updated when they tap, but it isn’t part of the JS module.

The function that appears to be causing the problem:
var x_direction = inputs.x < 0 ? “in” : “out”;

var y_direction = inputs.y < 0 ? "down" : "up";

var label = "0 center";

// If abs value of coordinates are non-zero and the same

if(inputs.x !== 0 && Math.abs(inputs.x) == Math.abs(inputs.y)){ 

  label = (Math.abs(inputs.x) * inputs.h_label_unit).toString() + " " + y_direction + " and " + x_direction;

}

else if(Math.abs(inputs.x) > Math.abs(inputs.y)){

  label = (Math.abs(inputs.x) * inputs.h_label_unit).toString() + " " + x_direction;

  if(inputs.y !== 0) { 

    label += ", " + (Math.abs(inputs.y) * inputs.v_label_unit).toString() + " " + y_direction; 

  }

}

else if(Math.abs(inputs.x) < Math.abs(inputs.y)) { 

  label = (Math.abs(inputs.y) * inputs.v_label_unit).toString() + " " + y_direction;

  if(inputs.x !== 0) { 

    label += ", " + (Math.abs(inputs.x) * inputs.h_label_unit).toString() + " " + x_direction; 

  }

}

return { result: label };

Any ideas?
App 188716.

Hmm. In general Android stability is improved in 2.4.33 and further in upcoming 2.5.X, but I’m not aware of any specific issues related to JS boxes, so it might be that these improvements don’t help the situation. However, if you think it’ll be a lot to convert to a formula, I would recommend waiting until 2.5.X is available until doing it, as perhaps the performance gains would help with this as well.

@Joel_D when the Preview app crashes on an Android device, it usually asks you to send feedback to the app developers. There you can also look into what should be sent and there in the stack trace.
Did you check what is on top?
Maybe out of memory or similar…
Best,
jo

I haven’t seen that. It just shuts down entirely.

Maybe you need to enable developer mode, e.g.

I already have that on, thanks though.

If you’d like to debug this further instead of waiting, you can debug Android by using console.log inside your JavaScript code to see where exactly it crashes. These logs you can see in AppGyver debugger.

Another option is using adb logcat from command line (requires downloading android developer tools etc). Through that you can see what sort of error is thrown right before the crash, but I would recommend trying our debugger first as Android generates a lot of logs.