dbankier / TiShadow

Quick Titanium previews across devices
http://tishadow.yydigital.com
Other
385 stars 122 forks source link

How to determine on which line the error and which file. #429

Open rotorgames opened 9 years ago

rotorgames commented 9 years ago

In the application, Hello World (Alloy). Try to call a nonexistent function test:

// buttom onclick
function doClick(e) {
    test(); // Function test does not exist.
}

$.index.open();

The console shows:

[ERROR] [android, 4.4.2, 192.168.43.103] {
  "message": "Uncaught ReferenceError: test is not defined",
  "lineOffset": 9,
  "line": 12,
  "title": "Runtime Error",
  "lineSource": "        test();",
  "sourceName": "undefined"
}

Try to call a nonexistent function in the controller

// buttom onclick
function doClick(e) {

}

$.index.open();

test(); // Function test does not exist.

The console shows:

[ERROR] [android, 4.4.2, 192.168.43.103] 
Type: ReferenceError
Message: test is not defined
File: eval at custom_require : api/PlatformRequire.js
Line: 24
At:   new Controller

Why line and even files that was a mistake, do not match? Perhaps, as you use the source map with tishadow? Without this, it becomes very difficult to debug.

dbankier commented 9 years ago

source maps would be good. I think you'll get the wrong lines with straight alloy as well (since it is precompiled).

rotorgames commented 9 years ago

@dbankier The problem with tishadow much deeper source map and here plays a small role. Tishadow uses eval that would fulfill the source code. In this case, you can only get the error string in the main file, any errors in the require hidden.

I'm working on source titanium, that would be able to use native tishadow require.

Developing code for IOS, I was finished, now working with Android.

Changes for IOS: https://github.com/rotorgames/titanium_mobile/commit/dce1cb1df8ff10b8f49b7bd6ba05471b5630e20d

P.S. Code for Android is almost finished, but I have little time. I hope it will soon appear, and I'll pull request in titanium.

dbankier commented 9 years ago

@rotorgames, that is TiShadow used to be back in 2012.

This commit roles it back and moves to the eval way (https://github.com/dbankier/TiShadow/commit/273ed75771369469a900980da3b1589ba0a29cc5)

These are the native commits back then for both iOS and Android that made it work. https://github.com/dbankier/titanium_mobile/commit/d332a846701df512003fdcb1fe791a6497348515 https://github.com/dbankier/titanium_mobile/commit/0b9b8abdf566ebc088edc93e0efd70e46904ebc7

I moved away from that since it meant having custom tishadow builds for every sdk release. That used to happen more frequently and it was a hassle to maintain.

It might be worth revisiting as native modules...

rotorgames commented 9 years ago

@dbankier I have a very different approach. Titanium does not need to know about the existence of tishadow. Titanium has only to provide methods for other plugins.

How it will work:

Tishadow adds tiapp.xml line parameter.

<Property name = "customDirectory" type = "string"> applicationDataDirectory:/{name}/{platform} </ property>

After that, any request require will first look in the folderapplicationDataDirectory:/{name}/{platform}

For example:

require ("lib/q.js") // /data/data/com.rotorgames.myappname/app_data/MyAppName/android/lib/q.js

Then, if the file in this folder will not be made a request to the default folder.

Thus, there is no mention of tishadow, and this method may be to Use any plugin or application developer.

Support Directory:

applicationDataDirectory tempDirectory applicationCacheDirectory externalStorageDirectory

Support Values

deploytype id publisher url name version description copyright guid familyTarget // Android: phone || tablet; IOS: Iphone, Ipad platform // ios || android family // iphone || android undName // My App Name == My_App_Name

dbankier commented 9 years ago

Right. nice! From what I understand, that would only work then with express/appified, unless the property can be modified at runtime. Also, I think you'd still need some standard require access... Good luck with the PR! Give a shout if you need help.

rotorgames commented 9 years ago

@dbankier I'll do a separate Pull Request for tishadow, which I will consider all the changes titanium.

Concerning, standard require access any ideas? How best to do it?

require ("app.js", bool);

Where bool boolean value, true if taken from a standard repository, if false or undefiend is taken from the custom warehouse.

Or make a separate function for this?

In general, is it necessary? I have done so if the require not find the file in the custom folder, it searches the standart folder, if there is not, then an error. This is convenient but there is no control.

Any ideas?

P.S. I think if I change the way of calling require appcelerator is unlikely to be thrilled by this.

dbankier commented 9 years ago

not sure if AppC will accept that, or this: perhaps better is require("app.js", root_path) either way it breaks the spec so I doubt you'll get it through.

rotorgames commented 9 years ago

@dbankier Done, Pull Request for Android and IOS. https://github.com/appcelerator/titanium_mobile/pull/6901

Soon prepare Pull Request for Tishadow

dbankier commented 9 years ago

nice - I'll be watching it.

xedef commented 8 years ago

Any updates on this? Would be awesome to have it.