nativescript-vscode-extension icon indicating copy to clipboard operation
nativescript-vscode-extension copied to clipboard

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

Open VladimirAmiorkov opened this issue 6 years ago • 1 comments

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):

  • CLI: 6.0.2
  • Cross-platform modules: 6.0.4
  • iOS Runtime: 6.0.1
  • Plugin(s):
  • VSCode: 1.36.1 (1.36.1)

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.

VladimirAmiorkov avatar Aug 01 '19 08:08 VladimirAmiorkov

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.

mbektchiev avatar Aug 05 '19 11:08 mbektchiev