Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Unexpected Error After Compiling to Windows
Started by danielbeer1376 Dec 17 2017 09:19 AM

- - - - -
16 replies to this topic

Best Answer Rob Miracle , 20 December 2017 - 10:42 AM

The Windows desktop app's sandbox is a different folder than the simulator's sandbox for your app.  I'm not on my Windows machine so I'm guessing at the path, but it's something like:

 

C:\Users\youruser\App Data\Roaming\App Name\documents

 

Note the App Data folder is likely hidden.

 

Rob

[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

danielbeer1376

[GLOBAL: userInfoPane.html]
danielbeer1376
  • Enthusiast

  • 63 posts
  • Corona SDK

Hello,

 

I've done some significant work on an app recently and after compiling to Windows received the following error, which did not appear at all after a thorough testing within the simulator.

12:05:05.804  Platform: Aspire X1470 / x64 / 6.1 / AMD Radeon HD 6410D / 4.1.10834 Compatibility Profile Context / 2017.3068 / en_CA | CA | en_CA | en
12:05:07.444  ERROR: Runtime error
12:05:07.444  ?:0: attempt to concatenate field '?' (a nil value)
12:05:07.444  stack traceback:
12:05:07.444  	?: in function '?'
12:05:07.444  	?: in function 'dispatchEvent'
12:05:07.444  	?: in function 'gotoScene'
12:05:07.444  	?: in function '?'
12:05:07.444  	?: in function <?:182>
12:05:22.544  Application closed with exit code: 0

I'm not exactly sure how to interpret this traceback and can't even tell where an error could be coming from. If you'd like to see the code itself I can also upload it, although I'd like to hopefully be able to figure it out myself after understanding the traceback and what could be causing an error like this.

 

Thanks in advance!



[TOPIC: post.html]
#2

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,641 posts
  • Corona SDK

1. Crashes with this error as soon as you start app?

2. Must be issue in first scene you go to.

3. Add require statement before gotoScene call like this:

require( scenePath ) 

This may tell you if there is a syntax or other error in the scene definition.  Don't leave this code in place.  It is a debugging trick.



[TOPIC: post.html]
#3

danielbeer1376

[GLOBAL: userInfoPane.html]
danielbeer1376
  • Enthusiast

  • 63 posts
  • Corona SDK

Thanks for the reply!

 

There doesn't seem to be an error in the scene definition. It doesn't occur right when I start the app, but after I try to load another scene from scene.menu. This error occurs when I call:

composer.gotoScene("scene.settings", {effect = "crossFade", time = 400, params = {}});

Which is called from scene.menu. (On its own scene.menu functions fine.) A very similar error (just different traceback) also occurs, likewise, when calling:

composer.gotoScene("scene.levelSelect", {effect = "crossFade", time = 400, params = {}});


[TOPIC: post.html]
#4

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,641 posts
  • Corona SDK

Same advice for that scene file.



[TOPIC: post.html]
#5

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,641 posts
  • Corona SDK

If you can't resolve this, consider a hit - A level 1 should probably cover a review to find this bug and perhaps others.



[TOPIC: post.html]
#6

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,613 posts
  • Enterprise

That generally means there is an error in the scene you're trying to go to.

 

You can try requiring the scene directly in main.lua i.e. require("scene.settings") and see if you can get the error messages being generated.

 

Rob



[TOPIC: post.html]
#7

danielbeer1376

[GLOBAL: userInfoPane.html]
danielbeer1376
  • Enthusiast

  • 63 posts
  • Corona SDK

I tried requiring all of the scene files in main.lua and none of them errored. The biggest thing that's confusing me is why this isn't erroring in the simulator but is erroring after I compile it



[TOPIC: post.html]
#8

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,613 posts
  • Enterprise

Well, the general cause of "It works in the simulator but not on device" is a filename case sensitivity problem.

 

Consider turning on debugging for composer:

 

composer.isDebug = true

 

https://docs.coronalabs.com/api/library/composer/isDebug.html

 

Rob



[TOPIC: post.html]
#9

danielbeer1376

[GLOBAL: userInfoPane.html]
danielbeer1376
  • Enthusiast

  • 63 posts
  • Corona SDK

I did some more debugging and found one of the issues. The following is the last few lines of my main file:

if loadsave.loadTable("data-settings.json") == nil then
	print("started settings file");
	
	local defaultSettings = {};
	defaultSettings.pSpeed = SPEED_SLOW;
	defaultSettings.tutorialIsOn = true;
	defaultSettings.sfxIsOn = true;
	defaultSettings.musicIsOn = true;
	
	loadsave.saveTable(defaultSettings, "data-settings.json");
end

composer.gotoScene("scene.menu");

I call the following from scene.settings:

settings = loadsave.loadTable("data-settings.json");

for k, v in pairs(settings) do print(k, v); end

And found that pSpeed is nil, no matter what value I set it to. Any ideas why this is happening? I've defined SPEED_SLOW earlier in the main as 2



[TOPIC: post.html]
#10

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,641 posts
  • Corona SDK

**UPDATE**: Don't forget to clear your documents folder before testing this.

 

 

Are you sure.... SPEED_SLOW is defined?  Have you confirmed it?  That code doesn't seem to show you've confirmed it.

 

Try this:

if loadsave.loadTable("data-settings.json") == nil then

   print( "SPEED_SLOW == ", SPEED_SLOW )
   
   print("started settings file");
	
   local defaultSettings = {};
   defaultSettings.pSpeed = SPEED_SLOW;
   defaultSettings.tutorialIsOn = true;
   defaultSettings.sfxIsOn = true;
   defaultSettings.musicIsOn = true;
	
   loadsave.saveTable(defaultSettings, "data-settings.json");
end

Edited by roaminggamer, 18 December 2017 - 05:19 PM.


[TOPIC: post.html]
#11

danielbeer1376

[GLOBAL: userInfoPane.html]
danielbeer1376
  • Enthusiast

  • 63 posts
  • Corona SDK

It's definitely defined: https://hastebin.com/ogejotutal.lua

 

However, it isn't printing "started save file" or "started settings file"



[TOPIC: post.html]
#12

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,613 posts
  • Enterprise

I would suggest a small change:

local defaultSettings = loadsave.loadTable("data-settings.json")

if defaultSettings == nil then

   print( "SPEED_SLOW == ", SPEED_SLOW )
   
   print("started settings file");
	
   defaultSettings = {};
   defaultSettings.pSpeed = SPEED_SLOW;
   defaultSettings.tutorialIsOn = true;
   defaultSettings.sfxIsOn = true;
   defaultSettings.musicIsOn = true;
	
   loadsave.saveTable(defaultSettings, "data-settings.json");
end

You basically are throwing away your settings that you're attempting to load since you're testing the return value but never store the read table.

 

Rob



[TOPIC: post.html]
#13

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,641 posts
  • Corona SDK

Good catch Rob.  I didn't even see that.  :)



[TOPIC: post.html]
#14

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,641 posts
  • Corona SDK

1. This should be resolved with Rob's catch.

 

It's definitely defined: https://hastebin.com/ogejotutal.lua

 

However, it isn't printing "started save file" or "started settings file"

 

 

2. You missed the point of my response.  You asserted something was true, but didn't show us you were verifying it at the point where it needed to be true.  

 

I was trying to demonstrate basic debugging steps to you. i.e. Verify at the point you need a variable that it is set.

 

The basic train of thought should be:

a. I set that variable in main.lua

b. I think it should still be set here where I'm about to use it.

c. However the value is not being 'saved'.

d. Let  me verify the variable is still set and visible here.


Edited by roaminggamer, 19 December 2017 - 08:41 AM.


[TOPIC: post.html]
#15

danielbeer1376

[GLOBAL: userInfoPane.html]
danielbeer1376
  • Enthusiast

  • 63 posts
  • Corona SDK

Thank you very much.

 

I think I've figured out a little more as to what is happening as well by doing some more debugging in this manner.

 

In the simulator the loadsave.loadTable("data-settings.json"); is returning nil upon initially launching it and having cleared the sandbox but is returning an empty table upon initially launching the compiled version that I built to Windows.

 

Also I realized that defaultSettings.pSpeed was causing other various errors in my files.

local defaultSettings = loadsave.loadTable("data-settings.json");

print(defaultSettings);

if (defaultSettings == nil) or (defaultSettings.pSpeed == nil) then
	print("started settings file");
	
	defaultSettings = {};

	defaultSettings.pSpeed = SPEED_SLOW;
	
	defaultSettings.tutorialIsOn = true;
	defaultSettings.sfxIsOn = true;
	defaultSettings.musicIsOn = true;
	
	loadsave.saveTable(defaultSettings, "data-settings.json");
end

print(defaultSettings.pSpeed);

This is what I ended up using to compensate for both cases.

 

However, now I'm wondering if I'm building correctly, because when I go to the level select page there is previous data saved however when I go into my settings scene and reset the data (through the application itself, not through Corona) it rights itself.

 

So, is it correct that after the game loads in the simulator I am then building it? Is there another way in which I need to open it? I feel like what's possibly happening as well as that I'm reading older data, however I'm not sure where it would be reading this data from.

 

Thanks again for all of your help. I really appreciate it. Sorry if I'm making some poor mistakes but I'm really intent on working through this and learning as this is something I enjoy doing quite a lot!



[TOPIC: post.html]
#16

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,613 posts
  • Enterprise

  Best Answer

The Windows desktop app's sandbox is a different folder than the simulator's sandbox for your app.  I'm not on my Windows machine so I'm guessing at the path, but it's something like:

 

C:\Users\youruser\App Data\Roaming\App Name\documents

 

Note the App Data folder is likely hidden.

 

Rob



[TOPIC: post.html]
#17

danielbeer1376

[GLOBAL: userInfoPane.html]
danielbeer1376
  • Enthusiast

  • 63 posts
  • Corona SDK

The Windows desktop app's sandbox is a different folder than the simulator's sandbox for your app.  I'm not on my Windows machine so I'm guessing at the path, but it's something like:

 

C:\Users\youruser\App Data\Roaming\App Name\documents

 

Note the App Data folder is likely hidden.

 

Rob

I believe I had an older settings file sitting around in here that didn't have pSpeed saved. I could load the table, but it wasn't actually complete with all of what I wanted to save from the most recent build.

 

This solves my problems. Thank you to all who helped and I'm glad you could help me improve my code as well even if it was a much simpler issue than it was at surface value!




[topic_controls]
[/topic_controls]