nativescript-community / nativescript-vscode-extension

A Visual Studio Code Extension for NativeScript
https://www.nativescript.org/visual-studio-code
Apache License 2.0
82 stars 32 forks source link

[iOS] [Simulator] Inspecting an `NSValue` object causes the debug session to hang #261

Open VladimirAmiorkov opened 4 years ago

VladimirAmiorkov commented 4 years ago

Environment Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

Describe the bug When you hit a breakpoint where there is an NSValue object and you try to inspect that object VS Code hangs and you can no longer proceed with the debug session.

To Reproduce Start any NativeScript app and add a breakpoint to this row: https://github.com/NativeScript/NativeScript/blob/09d370919f909aa4f89a350c04fd9d80b76fe9ca/tns-core-modules/application/application.ios.ts#L158. Try to inspect it and after that go to the next row in the debug session.

Expected behavior Inspecting an NSValue object works.

Sample project

Workaround Doing the same using Chrome Dev tools works as expected.

mbektchiev commented 4 years ago

This crash is related to the fact that VS Code tries to read all properties of an object when inspecting it. NSValue has many properties that interpret the wrapped object as different types (e.g. CGPointValue, CGVectorValue, CGRectValue etc.). Depending on the actual value of the object, only valid interpretations succeed, while the others will throw an Objective-C exception (e.g. [[NSValue valueWithCGSize: CGSize {15,10} ] rectValue] will throw). That leads to app crashes on the simulator because of a known issue in the iOS runtime (https://github.com/NativeScript/ios-runtime/issues/1044).

As a workaround (until the main issue gets fixed), you can debug your app on a real device instead of the simulator.