Guest User

thanksgarmin^2

a guest
Jan 8th, 2025
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. Details:
  2.  
  3. > I doubt, because even this can reproduce it:
  4.  
  5. > var x = foo <= 0;
  6.  
  7. If that's the case, then why is it necessary to press play to trigger the crash in the first place?
  8.  
  9. What's the exact error/exception that you are seeing?
  10.  
  11. If even "var x = foo <= 0;" causes an exception, then it seems that only possible way an error would be triggered or an exception would be thrown if foo is non-numeric (e.g. null or String).
  12.  
  13. Anyway, I was able to recreate the problem too.
  14.  
  15. My observations (in the sim, with fr955):
  16.  
  17. - with the original formulation of the code (with the double ternary) in SDK 8.0.0-beta, the code indeed crashes when activity data is simulated, with the following error:
  18.  
  19. Error: Unexpected Type Error
  20. Details: Failed invoking <symbol>
  21.  
  22. - When I switched back to SDK 7.4.3, the original code indeed did not crash when activity data is simulated
  23.  
  24. - with the original code, it's also possible to crash the code by selecting Reset All App Data (in SDK 8.0.0-beta). This kinda makes sense, as foo may actually be null in this case (and null can't be compared to 0 using <=). Or at least I was able to do so while the sim needed access to my Connect IQ credentials (as it was unable to grab them from my MacOS keychain). Once I provided those, I was unable to get the code to crash by selecting Reset All App Data. So it seems this might be a bug / loophole in the sim where sometimes Reset All App Data will cause properties with a default value to be returned as null
  25.  
  26. - the second formulation (var x = foo <= 0;) does not crash when activity data is simulated (how could that possibly make it crash?). I assume it would've crashed if the sim was in the state where Reset All Data would make foo null, if I pressed Reset All Data. As I was no longer in that state, I was unable to make this code crash
  27.  
  28. I rewrote the original code as if-else statements, based on my understanding of the original logic, and indeed, it no longer crashes on SDK 8.0.0-beta.
  29.  
  30. if (foo <= 0) {
  31. heartRate = info.currentHeartRate;
  32. } else {
  33. if (bar != null) {
  34. heartRate = bar.average;
  35. } else {
  36. heartRate = null;
  37. }
  38. }
  39.  
  40. This suggests that when the code does crash due to triggering activity data, somehow the fact that info.currentHeartRate is non-zero/non-null leads bar.average to be evaluated, which crashes because bar is null
Advertisement
Add Comment
Please, Sign In to add comment