Skip to content

{N} app crashes when inspecting SearchBar with VSCode debugger #1085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DimitarTachev opened this issue Feb 19, 2019 · 1 comment
Closed
Assignees
Milestone

Comments

@DimitarTachev
Copy link
Contributor

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: 5.2.0
  • Cross-platform modules: 5.2.0
  • iOS Runtime: 5.2.0

To Reproduce

  1. tns create jsApp --js && cd jsApp && code .
  2. Replace the <Button with a <SearchBar.
  3. Replace your onTap method with the one below:
viewModel.onTap = (args) => {
    const sb = args.object;
    const native = sb.nativeView;
    console.log(native);
};
  1. Set a breakpoint inside the above-mentioned method.
  2. Start a simulator e.g. iPhone X with iOS 12.1.
  3. Click Launch on iOS from VSCode.
  4. Try to inspect the nativeView of the SearchBar.
  5. The VSCode debugging will crash and the app will freeze.
@mbektchiev
Copy link
Contributor

The reason for the issue is that optional unimplemented methods were returned as supported by the JS wrapper object.
It lead to crashes only on Simulator because of #1044, on real devices it only logs errors when the VS Code debugger tries to read their values:

-[UISearchBarImpl collisionBoundingPath]: unrecognized selector sent to instance 0x106142820

-[UISearchBarImpl collisionBoundsType]: unrecognized selector sent to instance 0x106142820

-[UISearchBarImpl coordinateSpace]: unrecognized selector sent to instance 0x106142820

mbektchiev added a commit that referenced this issue Feb 25, 2019
* Add `isImplementedInClass` and `isAvailableInClass` methods in
`PropertyMeta` and `MethodMeta` which additionally check whether a Class
instance supports a given optional method
* Use `isAvailableInClass` instead of `isAvailable` in `getOwnPropertySlot` of
`ObjCPrototype`, `ObjCConstructorBase`, `ObjCConstructorNative`
* Add `findInterfaceMeta` function with fallback to base interface
if the desired one is unavailable in the current SDK version
* Add `encodeVersion` `getMajorVersion` and `getMinorVersion` helpers
* Remove hacky patch from `ObjCMethodWrapper::preInvocation` which
fixed the symptoms of #978 but not its root cause
* Modify fixtures and add test cases for methods availability in
`InheritanceTests.js`
* Add test case for unavailable base class

refs #1085
@mbektchiev mbektchiev changed the title VSCode debugger crashes when inspecting SearchBar {N} app crashes when inspecting SearchBar with VSCode debugger Feb 25, 2019
mbektchiev added a commit that referenced this issue Feb 27, 2019
* Add `isImplementedInClass` and `isAvailableInClass` methods in
`PropertyMeta` and `MethodMeta` which additionally check whether a Class
instance supports a given optional method

* Use `isAvailableInClass` instead of `isAvailable` in `getOwnPropertyNames`
of `ObjCPrototype`, `ObjCConstructorBase`, `ObjCConstructorNative` and
in `materializeProperties` of `ObjCConstructorNative`

* Filter via `isAvailableInClass` in `BaseClassMeta`'s various
method and property getters

* Change `MembersCollection` to be a `HashSet` to avoid adding the same
member more than once when collecting them from the inheritance chain

* Remove unused functions from `BaseClassMeta`

* Add `findInterfaceMeta` function with fallback to the base interface
if the desired one is unavailable in the current SDK version (instead
of the hardcoded `NSObject` so far)

* Remove hacky patch from `ObjCMethodWrapper::preInvocation` which
fixed the symptoms of #978 but not its root cause. Namely, that
unimplemented optional methods were returned as available properties
in `getOwnPropertyNames`.

* Modify fixtures and add test cases for methods availability in
`InheritanceTests.js`

* Add test case for unavailable base class

* Add test case for property with custom selector. The getter of
`secureTextEntry`(`isSecureText`) overrides the default `secureTextEntry`

* Add `encodeVersion` `getMajorVersion` and `getMinorVersion` helpers

refs #1085
@mbektchiev mbektchiev modified the milestones: 5.2.1, 5.3.0 Feb 27, 2019
mbektchiev added a commit that referenced this issue Feb 28, 2019
* Add `isImplementedInClass` and `isAvailableInClass` methods in
`PropertyMeta` and `MethodMeta` which additionally check whether a Class
instance supports a given optional method

* Use `isAvailableInClass` instead of `isAvailable` in `getOwnPropertyNames`
of `ObjCPrototype`, `ObjCConstructorBase`, `ObjCConstructorNative` and
in `materializeProperties` of `ObjCConstructorNative`

* Filter via `isAvailableInClass` in `BaseClassMeta`'s various
method and property getters

* Change `MembersCollection` to be a `HashSet` to avoid adding the same
member more than once when collecting them from the inheritance chain

* Remove unused functions from `BaseClassMeta`

* Add `findInterfaceMeta` function with fallback to the base interface
if the desired one is unavailable in the current SDK version (instead
of the hardcoded `NSObject` so far)

* Remove hacky patch from `ObjCMethodWrapper::preInvocation` which
fixed the symptoms of #978 but not its root cause. Namely, that
unimplemented optional methods were returned as available properties
in `getOwnPropertyNames`.

* Modify fixtures and add test cases for methods availability in
`InheritanceTests.js`

* Add test case for unavailable base class

* Add test case for property with custom selector in ApiTests. The getter
of `secureTextEntry`(`isSecureText`) overrides the default `secureTextEntry`

* Add `encodeVersion` `getMajorVersion` and `getMinorVersion` helpers

refs #1085
mbektchiev added a commit that referenced this issue Feb 28, 2019
* Add `isImplementedInClass` and `isAvailableInClass` methods in
`PropertyMeta` and `MethodMeta` which additionally check whether a Class
instance supports a given optional method

* Use `isAvailableInClass` instead of `isAvailable` in `getOwnPropertyNames`
of `ObjCPrototype`, `ObjCConstructorBase`, `ObjCConstructorNative` and
in `materializeProperties` of `ObjCConstructorNative`

* Filter via `isAvailableInClass` in `BaseClassMeta`'s various
method and property getters

* Change `MembersCollection` to be a `HashSet` to avoid adding the same
member more than once when collecting them from the inheritance chain

* Remove unused functions from `BaseClassMeta`

* Add `findInterfaceMeta` function with fallback to the base interface
if the desired one is unavailable in the current SDK version (instead
of the hardcoded `NSObject` so far)

* Remove hacky patch from `ObjCMethodWrapper::preInvocation` which
fixed the symptoms of #978 but not its root cause. Namely, that
unimplemented optional methods were returned as available properties
in `getOwnPropertyNames`.

* Modify fixtures and add test cases for methods availability in
`InheritanceTests.js`

* Add test case for unavailable base class

* Add test case for property with custom selector in ApiTests. The getter
of `secureTextEntry`(`isSecureText`) overrides the default `secureTextEntry`

* Add `encodeVersion` `getMajorVersion` and `getMinorVersion` helpers

refs #1085
@Natalia-Hristova Natalia-Hristova self-assigned this Mar 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants