Skip to content
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

[iOS] Rendering Picker triggers recursive call leads to app crash #9055

Closed
fwang opened this issue Jul 28, 2016 · 5 comments
Closed

[iOS] Rendering Picker triggers recursive call leads to app crash #9055

fwang opened this issue Jul 28, 2016 · 5 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@fwang
Copy link

fwang commented Jul 28, 2016

React Native: 0.30.0
iOS: 9.3

Code triggered crash:
<Picker
style={styles.picker}
selectedValue={this.state.selected1}
onValueChange={this.onValueChange.bind(this, 'selected1')}>
<Picker.Item label="hello" value="key0" />
<Picker.Item label="world" value="key1" />
</Picker>

Crash stack trace:
#0 0x0000000106ca803d in (anonymous namespace)::AutoreleasePoolPage::pop(void*) ()
#1 0x0000000107c90736 in _CFAutoreleasePoolPop ()
#2 0x0000000107dbb17c in -_CFXNotificationRegistrar find:object:observer:enumerator:
#3 0x0000000107c6a679 in _CFXNotificationPost ()
#4 0x0000000104e51cd9 in -NSNotificationCenter postNotificationName:object:userInfo:
#5 0x0000000105680e6c in -UIScrollView(UIScrollViewInternal) _setContentOffset:animated:animationCurve:animationAdjustsForContentOffsetDelta:
#6 0x0000000105cccba3 in -UIPickerTableView _scrollRowAtIndexPathToSelectionBar:animated:

(#67954 ~ #67964 repeats)
#67954 0x00000001056832ca in -UIScrollView(UIScrollViewInternal) _adjustContentOffsetIfNecessary
#67955 0x000000010567f858 in -UIScrollView(UIScrollViewInternal) _stopScrollingNotify:pin:tramplingDragFlags:
#67956 0x000000010567f918 in -UIScrollView(UIScrollViewInternal) _stopScrollingAndZoomingAnimationsPinningToContentViewport:tramplingDragFlags:
#67957 0x0000000105cccb2f in -UIPickerTableView _scrollRowAtIndexPathToSelectionBar:animated:
#67958 0x0000000105ccd404 in -UIPickerTableView _updateContentInsets
#67959 0x0000000105ccd1d8 in -UIPickerTableView _rectChangedWithNewSize:oldSize:
#67960 0x00000001056ef79a in -UITableView setBounds:
#67961 0x0000000105cce700 in -UIPickerTableView setBounds:
#67962 0x000000010566974c in -UIScrollView setContentOffset:
#67963 0x00000001056f082e in -UITableView setContentOffset:
#67964 0x0000000105ccdade in -UIPickerTableView _setContentOffset:notify:
#67965 0x0000000105e4e523 in -UIPickerColumnView _moveTableViewIfNecessary:toContentOffset:
#67966 0x0000000105e4e63c in -UIPickerColumnView _pickerTableViewDidChangeContentOffset:
#67967 0x0000000105ccda6e in -UIPickerTableView _notifyContentOffsetChange
#67968 0x0000000105cccbbc in -UIPickerTableView _scrollRowAtIndexPathToSelectionBar:animated:
#67969 0x0000000105cccf33 in -UIPickerTableView selectRow:animated:notify:
#67970 0x0000000105584a6b in -UIPickerView _resetSelectionOfTables
#67971 0x00000001055848f7 in __30-[UIPickerView layoutSubviews]_block_invoke ()
#67972 0x0000000105650680 in +UIView(Animation) performWithoutAnimation:
#67973 0x0000000105582393 in -UIPickerView layoutSubviews
#67974 0x0000000105585b24 in -UIPickerView _selectRow:inComponent:animated:notify:
#67975 0x0000000103f18b8d in __30-[RCTPicker setSelectedIndex:]_block_invoke at /Users/bb/Sites/Anomaly/ToolbeamReact/node_modules/react-native/React/Views/RCTPicker.m:46
#67976 0x00000001093c8d9d in _dispatch_call_block_and_release ()
#67977 0x00000001093e93eb in _dispatch_client_callout ()
#67978 0x00000001093d11ef in _dispatch_main_queue_callback_4CF ()
#67979 0x0000000107d020f9 in CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE ()
#67980 0x0000000107cc3b99 in __CFRunLoopRun ()
#67981 0x0000000107cc30f8 in CFRunLoopRunSpecific ()
#67982 0x000000010a9f5ad2 in GSEventRunModal ()
#67983 0x00000001055a0f09 in UIApplicationMain ()
#67984 0x0000000103d9923f in main at /Users/bb/Sites/Anomaly/ToolbeamReact/ios/Toolbeam/main.m:16
#67985 0x000000010941d92d in start ()

It does not crash if no Picker.Items are included in the tag. Please let me know if more detail is required.

Thanks,
Frank

@jayair
Copy link

jayair commented Jul 28, 2016

I'm having the same issue as well. Just simply adding a Picker with an Item causes the app to crash with an EXC_BAD_ACCESS.

@dc85
Copy link

dc85 commented Jul 29, 2016

+1 Having the same with PickerIOS.

@cpruijsen
Copy link

cpruijsen commented Jul 30, 2016

@fwang I tried to replicate Picker errors with Item components - and was not able to.

The Picker element with Picker.Item elements was working fine for me with the below code:

import React, { Component, } from 'react'
import { View, Picker} from 'react-native'

class TestPicker extends Component {
  constructor(props) {
    super(props)
    this.state = {
      language: 'java'
    }
  }

  render() {
    return (
      <View>
        <Picker selectedValue={this.state.language}
                onValueChange={(lang) => this.setState({language: lang})}>
          <Picker.Item label="Java" value="java" />
          <Picker.Item label="JavaScript" value="js" />
        </Picker>

      </View>
    )
  }
}

export default TestPicker

I notice the code you reference also comes from the docs at https://facebook.github.io/react-native/docs/picker.html - it is a known issue they reference outdated versions of the API with methods such as const someClass = React.createClass({}) instead of class someClass extends Component and getInitialState instead of just setting the state in the class constructor.

I suggest using the Picker syntax I used above, it should work better :)
Happy to help otherwise - sharing the rest of your component / page might be helpful.

@fwang
Copy link
Author

fwang commented Jul 31, 2016

@cpruijsen Thank for your help. I have tried your code in my current project and had no luck. Weird. I will create a new project to try it out and let you know.

Thanks!

@fwang
Copy link
Author

fwang commented Aug 12, 2016

The issue ended up being a third party UIScrollView category we included that's capture the Picker setContentInset event.

Thanks again @cpruijsen for your help.

Closing this issue as it is not React related.

@fwang fwang closed this as completed Aug 12, 2016
@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

5 participants