Closed NathanaelA closed 6 years ago
Hi, @NathanaelA
Thank you for the detailed description of the issue, however I was unable to reproduce it.
I tried adding new NSArray().objectAtIndex(5)
to the application, which causes an NSException
but it is correctly displayed every time during tns run ios
. If you could provide a sample application, which illustrates the issue, that would be extremely helpful.
As a workaround in such cases, we recommend running tns device log
in a separate console where no logs will be filtered out and where you should be able to see everything.
Here you go; I just created a use case where this crashes the real device with no output beyond the first console.log('Hi!')
function crashMe() {
console.log("Hi!");
var someString=null;
let truncated = NSString.stringWithUTF8String(someString);
let trunc2 = NSString.stringWithUTF8String(truncated);
console.log("hello");
}
The above code is totally invalid and if you use idevicesyslog you will see:
Oct 6 12:51:00 Nathanaels-iPhone test3(NativeScript)[355] <Notice>: CONSOLE LOG file:///app/main-view-model.js:12:14: Hi!
Oct 6 12:51:00 Nathanaels-iPhone test3[355] <Notice>: *** JavaScript call stack:
(
0 stringWithUTF8String@[native code]
1 crashMe@file:///app/main-view-model.js:14:49
2 onTap@file:///app/main-view-model.js:33:16
3 notify@file:///app/tns_modules/tns-core-modules/data/observable/observable.js:100:37
4 _emit@file:///app/tns_modules/tns-core-modules/data/observable/observable.js:120:24
5 tap@file:///app/tns_modules/tns-core-modules/ui/button/button.js:207:24
6 UIApplicationMain@[native code]
7 start@file:///app/tns_modules/tns-core-modules/application/application.js:211:26
8 anonymous@file:///app/app.js:10:18
9 evaluate@[native code]
10 moduleEvaluation@:1:11
11 @:7:50
12 promiseReactionJob@:1:11
)
Oct 6 12:51:00 Nathanaels-iPhone test3(CoreFoundation)[355] <Notice>: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSString stringWithUTF8String:]: NULL cString'
*** First throw call stack: ...
TNS only shows:
CONSOLE LOG file:///app/main-view-model.js:12:14: Hi!
@NathanaelA
Thank you for the provided repro.
I can confirm that the exception log is missing in the output of tns run ios
command (and related commands, which should print the console logs, like tns debug ios
). The problem is in the filtering, which we apply in order to show only logs from current application.
We'll try to address the issue, but meanwhile you can use tns device log
in a separate console. This will show the full device log, where the exception will be visible. Note you do not need any external tools to run this command - it is just a regular CLI command.
@Mitko-Kerezov - Well that is interesting to know that tns device log
would have allowed me to see the missing exceptions. ;-) But since I also frequently run into #3106 also, using another tool idevicesyslog
eliminates having tns mess up and strip out many of my "console.log" statements. So, I personally would recommend people use idevicesyslog
over tns for logging from a real device until the cause of 3106 is discovered as it actually solves both 3105 and 3106 at the same time. :grinning:
Hey @NathanaelA ,
It looks like the problem in #3106 is again the filtering and most probably the many logs your application has. In fact, I believe the problem is that we receive only part of the message (CONSOLE ERROR file:///app/tns_modules
), it matches our regex, we print it and the second part of the error (nativescript-angular/zone-js/dist/zone-nativescript.js:571:22: Error: Uncaught (in promise): Error: Animation cancelled.
) is received after that, but it does not match our regex filtering.
Anyway, I wanted to note that the problem is the filtering, but tns device log
does not apply any filter - it just prints to the stdout everything from device logs, so the whole error from #3106 will be shown. Of course, you can use idevicesyslog
or tns device log
- it is up to you to decide which one is most suitable for you.
Thank you again for the detailed report of this issue and providing the workaround, so anyone that hits the same problem will be able to find it and use it easily.
@rosen-vladimirov - Awesome, it is good to know that once tns
fixes the ios 11 logging issues; that tns device log
would work as a generic logging system so that people don't have to install anything else. :+1:
Hi @NathanaelA,
We're improving our logging for iOS platform. Can you please give it a try?
npm install -g nativescript@rc
Please, provide the details below:
Doing a standard
tns run ios
will eat exceptions that occur.Did you verify this is a real problem by searching
yes
Tell us about the problem
For some reason the newer versions of TNS seems to eat exceptions. It logged my
CONSOLE
logs fine then the app appeared to freeze. No output, it would allow updates to restart the app; but no exception/crash was logged to the screen. Finally after a lot of wasted time, running it in xcode; I got to see the actual exception report so I could fix the issue.Which platform(s) does your issue occur on?
IOS
Please provide the following version numbers that your issue occurs with:
Please tell us how to recreate the issue in as much detail as possible.
I'm not 100% sure if it eliminates all exceptions, but NONE of this printed in TNS:
Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.
Should be something simple like do something that causes a NSException and see if TNS reports it.