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 crash when picking dates #848

Open
Anyamborogass opened this issue Dec 7, 2023 · 3 comments
Open

IOS crash when picking dates #848

Anyamborogass opened this issue Dec 7, 2023 · 3 comments

Comments

@Anyamborogass
Copy link

Anyamborogass commented Dec 7, 2023

Bug report

Summary

I am using @react-native-community/datetimepicker version 7.6.2 in my Expo application and sometimes when the user is picking a datetime date (happens once in 10 tries) my app just crash with the mentioned below.

This only happens in IOS, on Android it works fine.

ezgif-3-8ce9169c14(1)

ERROR  Your app just crashed. See the error below.
NSGenericException: *** Collection <__NSArrayM: 0x2836ee070> was mutated while being enumerated.
  0   CoreFoundation                      0x000000018193bc74 EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 601204
  1   libobjc.A.dylib                     0x0000000199167ee4 objc_exception_throw + 56       
  2   CoreFoundation                      0x0000000181a06120 EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 1429792
  3   UIKitCore                           0x0000000184a1df1c 9D301877-2593-385C-8F72-F075AA0B48FA + 14917404
  4   UIKitCore                           0x0000000184a026f4 9D301877-2593-385C-8F72-F075AA0B48FA + 14804724
  5   eKisllat                            0x0000000103fa7440 -[RCTView hitTest:withEvent:] + 
616
  6   eKisllat                            0x0000000103fa7440 -[RCTView hitTest:withEvent:] + 
616
  7   eKisllat                            0x0000000103fa7440 -[RCTView hitTest:withEvent:] + 
616
  8   UIKitCore                           0x0000000183da5bf0 9D301877-2593-385C-8F72-F075AA0B48FA + 1842160
  9   UIKitCore                           0x00000001840bc620 9D301877-2593-385C-8F72-F075AA0B48FA + 5080608
  10  CoreFoundation                      0x00000001818b609c EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 53404
  11  CoreFoundation                      0x00000001818f1ad4 EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 297684
  12  UIKitCore                           0x00000001840448d4 9D301877-2593-385C-8F72-F075AA0B48FA + 4589780
  13  UIKitCore                           0x0000000183ffca1c 9D301877-2593-385C-8F72-F075AA0B48FA + 4295196
  14  eKisllat                            0x0000000103fa7440 -[RCTView hitTest:withEvent:] + 
616
  15  eKisllat                            0x0000000103fa7440 -[RCTView hitTest:withEvent:] + 
616
  16  eKisllat                            0x0000000103fa7440 -[RCTView hitTest:withEvent:] + 
616
  17  eKisllat                            0x0000000103fa7440 -[RCTView hitTest:withEvent:] + 
616
  18  eKisllat                            0x0000000103fa7440 -[RCTView hitTest:withEvent:] + 
616
  19  eKisllat                            0x0000000103fa7440 -[RCTView hitTest:withEvent:] + 
616
  20  eKisllat                            0x0000000103fa7440 -[RCTView hitTest:withEvent:] + 
616
  21  eKisllat                            0x0000000103fa7440 -[RCTView hitTest:withEvent:] + 
616
  22  eKisllat                            0x0000000103fa7440 -[RCTView hitTest:withEvent:] + 
616
  23  UIKitCore                           0x0000000183da5bf0 9D301877-2593-385C-8F72-F075AA0B48FA + 1842160
  24  UIKitCore                           0x00000001840bc620 9D301877-2593-385C-8F72-F075AA0B48FA + 5080608
  25  CoreFoundation                      0x00000001818b609c EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 53404
  26  CoreFoundation                      0x00000001818f1ad4 EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 297684
  27  UIKitCore                           0x00000001840448d4 9D301877-2593-385C-8F72-F075AA0B48FA + 4589780
  28  UIKitCore                           0x0000000183da5bf0 9D301877-2593-385C-8F72-F075AA0B48FA + 1842160
  29  UIKitCore                           0x00000001840bc620 9D301877-2593-385C-8F72-F075AA0B48FA + 5080608
  30  CoreFoundation                      0x00000001818b609c EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 53404
  31  CoreFoundation                      0x00000001818f1ad4 EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 297684
  32  UIKitCore                           0x00000001840448d4 9D301877-2593-385C-8F72-F075AA0B48FA + 4589780
  33  eKisllat                            0x0000000103fa7440 -[RCTView hitTest:withEvent:] + 
616
  34  eKisllat                            0x0000000103fa7440 -[RCTView hitTest:withEvent:] + 
616
  35  eKisllat                            0x0000000103fa7440 -[RCTView hitTest:withEvent:] + 
616
  36  eKisllat                            0x0000000103fa7440 -[RCTView hitTest:withEvent:] + 
616
  37  eKisllat                            0x0000000103fa7440 -[RCTView hitTest:withEvent:] + 
616
  38  eKisllat                            0x0000000103fa7440 -[RCTView hitTest:withEvent:] + 
616
  39  eKisllat                            0x0000000103f675b0 -[RCTRootContentView hitTest:withEvent:] + 96
  40  UIKitCore                           0x0000000183da5bf0 9D301877-2593-385C-8F72-F075AA0B48FA + 1842160
  41  UIKitCore                           0x00000001840bc620 9D301877-2593-385C-8F72-F075AA0B48FA + 5080608
  42  CoreFoundation                      0x00000001818b609c EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 53404
  43  CoreFoundation                      0x00000001818f1ad4 EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 297684
  44  UIKitCore                           0x00000001840448d4 9D301877-2593-385C-8F72-F075AA0B48FA + 4589780
  45  eKisllat                            0x0000000103f69e5c -[RCTRootView hitTest:withEvent:] + 96
  46  UIKitCore                           0x0000000183da5bf0 9D301877-2593-385C-8F72-F075AA0B48FA + 1842160
  47  UIKitCore                           0x00000001840bc620 9D301877-2593-385C-8F72-F075AA0B48FA + 5080608
  48  CoreFoundation                      0x00000001818b609c EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 53404
  49  CoreFoundation                      0x00000001818f1ad4 EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 297684
  50  UIKitCore                           0x00000001840448d4 9D301877-2593-385C-8F72-F075AA0B48FA + 4589780
  51  UIKitCore                           0x0000000183c4aa10 9D301877-2593-385C-8F72-F075AA0B48FA + 420368
  52  UIKitCore                           0x0000000183da5bf0 9D301877-2593-385C-8F72-F075AA0B48FA + 1842160
  53  UIKitCore                           0x00000001840bc620 9D301877-2593-385C-8F72-F075AA0B48FA + 5080608
  54  CoreFoundation                      0x00000001818b609c EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 53404
  55  CoreFoundation                      0x00000001818f1ad4 EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 297684
  56  UIKitCore                           0x00000001840448d4 9D301877-2593-385C-8F72-F075AA0B48FA + 4589780
  57  UIKitCore                           0x0000000183c4b3d4 9D301877-2593-385C-8F72-F075AA0B48FA + 422868
  58  UIKitCore                           0x0000000183da5bf0 9D301877-2593-385C-8F72-F075AA0B48FA + 1842160
  59  UIKitCore                           0x00000001840bc620 9D301877-2593-385C-8F72-F075AA0B48FA + 5080608
  60  CoreFoundation                      0x00000001818b609c EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 53404
  61  CoreFoundation                      0x00000001818f1ad4 EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 297684
  62  UIKitCore                           0x00000001840448d4 9D301877-2593-385C-8F72-F075AA0B48FA + 4589780
  63  UIKitCore                           0x0000000183da5bf0 9D301877-2593-385C-8F72-F075AA0B48FA + 1842160
  64  UIKitCore                           0x0000000183ca8aa8 9D301877-2593-385C-8F72-F075AA0B48FA + 805544
  65  UIKitCore                           0x000000018411c5f8 9D301877-2593-385C-8F72-F075AA0B48FA + 5473784
  66  UIKitCore                           0x0000000183d67e58 9D301877-2593-385C-8F72-F075AA0B48FA + 1588824
  67  UIKitCore                           0x0000000183e874e4 9D301877-2593-385C-8F72-F075AA0B48FA + 2766052
  68  UIKitCore                           0x0000000183da31dc 9D301877-2593-385C-8F72-F075AA0B48FA + 1831388
  69  UIKitCore                           0x0000000183c2a130 9D301877-2593-385C-8F72-F075AA0B48FA + 287024
  70  UIKitCore                           0x0000000183c2a668 9D301877-2593-385C-8F72-F075AA0B48FA + 288360
  71  UIKitCore                           0x0000000184ad7258 9D301877-2593-385C-8F72-F075AA0B48FA + 15675992
  72  UIKitCore                           0x0000000183d42f08 9D301877-2593-385C-8F72-F075AA0B48FA + 1437448
  73  UIKitCore                           0x0000000183d495fc 9D301877-2593-385C-8F72-F075AA0B48FA + 1463804
  74  UIKitCore                           0x0000000183d3faf0 9D301877-2593-385C-8F72-F075AA0B48FA + 1424112
  75  UIKitCore                           0x0000000183d44f0c 9D301877-2593-385C-8F72-F075AA0B48FA + 1445644
  76  CoreFoundation                      0x000000018195c448 EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 734280
  77  CoreFoundation                      0x000000018196c578 EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 800120
  78  CoreFoundation                      0x00000001818ae734 EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 22324
  79  CoreFoundation                      0x00000001818b3e08 EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 44552
  80  CoreFoundation                      0x00000001818c7174 CFRunLoopRunSpecific + 572      
  81  GraphicsServices                    0x00000001a2402988 GSEventRunModal + 160
  82  UIKitCore                           0x00000001840c9a88 9D301877-2593-385C-8F72-F075AA0B48FA + 5134984
  83  UIKitCore                           0x0000000183e62f78 UIApplicationMain + 336
  84  eKisllat                            0x0000000102da50bc main + 96
  85  dyld                                0x000000010a3384d0 start + 444

Reproducible sample code

import React, { useState } from 'react';
import { View, Text, TouchableOpacity, Platform } from 'react-native';
import DateTimePicker from '@react-native-community/datetimepicker';

const myDatePicker = () => {
  const [show, setShow] = useState(false);
  const [date, setDate] = useState(new Date());
  const [dateText, setDateText] = useState('');

  const onDateChange = (event, selectedDate) => {
    const currentDate = selectedDate;
    setDate(selectedDate);
    setDateText(formatDate(currentDate)); // Formats date value to string like "2023-12-07"
  };

	function formatDate(date) {
	  var d = new Date(date),
		  month = '' + (d.getMonth() + 1),
		  day = '' + d.getDate(),
		  year = d.getFullYear();

	  if (month.length < 2) 
		  month = '0' + month;
	  if (day.length < 2) 
		  day = '0' + day;

	  return [year, month, day].join('-');
	}

  return (
    <View
      style={{
	  flex:1,
        alignItems: 'center',
        justifyContent: 'center',
        flexDirection: 'row',
		backgroundColor: 'black'
      }}
    >
      <Text>Születési dátum</Text>

      <TouchableOpacity
        onPress={() => setShow(!show)}
      >
        {!dateText ? 
          <Text>Select date</Text>
        : 
          <Text>{dateText}</Text>
        }
      </TouchableOpacity>
    </View>

    {show && (
      <DateTimePicker
        value={date}
        mode={'date'}
        display={Platform.OS === 'ios' ? 'spinner' : 'default'}
        onChange={onDateChange}
        textColor={'white'}
        theme={'light'}
      />
    )}
  );
};

export default myDatePicker;

Steps to reproduce

  1. Create new Expo project
  2. Install latest datetimepicker
  3. Create development build with eas
  4. Run the example code and pick dates for 10 seconds

Describe what you expected to happen:

  1. The application crashes

Environment info

Expo version:

"expo": "^49.0.0"

npx react-native info output:

System:
  OS: Windows 10 10.0.19045
  CPU: (8) x64 Intel(R) Core(TM) i7-4771 CPU @ 3.50GHz
  Memory: 7.10 GB / 15.92 GB
Binaries:
  Node:
    version: 18.12.1
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 1.22.19
    path: ~\AppData\Roaming\npm\yarn.CMD
  npm:
    version: 9.2.0
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK: Not Found
IDEs:
  Android Studio: AI-213.7172.25.2113.9123335
  Visual Studio: Not Found
Languages:
  Java: Not Found
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.4
    wanted: 0.72.4
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

datetimepicker version: 7.6.2

iOS: 15.8

@TrooperZ
Copy link

TrooperZ commented Mar 3, 2024

I have the same issue occurring to me but with picking time. iOS 17.4.

Works fine on android but crashes on ios. (I did manage to get 1 lucky instance of it not crashing on ios)

@singhroshan18
Copy link

singhroshan18 commented Jul 20, 2024

My iOS app is also crashing when clicking on the Date, what's the solution ?

@EvilSpartans
Copy link

Same for me here, crash on iOS. Did you find a solution ? Its because of onChange props.

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