nativescript-modal-datetimepicker icon indicating copy to clipboard operation
nativescript-modal-datetimepicker copied to clipboard

Crashes on iOS 14.4 when selecting 'Cancel' or 'Done'

Open enich-dev opened this issue 4 years ago • 10 comments

Make sure to check the demo app(s) for sample usage


Issue occurs on the sample app and my app.


Make sure to check the existing issues in this repository


Checked.


If the demo apps cannot help and there is no issue for your problem, tell us about it

Please, ensure your title is less than 63 characters long and starts with a capital letter.

This occurred after upgrading from NS6 to NS7. Crash occurring on iOS intermittently (about 50% of the time) after selecting either 'Cancel' or 'Done' on the datepicker, regardless of PickerOptions or the date selected. If the crash does not occur then it will not occur until the app is closed, reopened, and you try again.


Which platform(s) does your issue occur on?

  • iOS/Android/Both
  • iOS/Android versions
  • emulator or device. What type of device?

Real device and emulator - iOS 14.4.


Please, provide the following version numbers that your issue occurs with:

  • CLI: (run tns --version to fetch it)
  • Cross-platform modules: (check the 'version' attribute in the node_modules/@nativescript/core/package.json file in your project)
  • Runtime(s): (look for the "tns-android" and "tns-ios" properties in the package.json file of your project)
  • Plugin(s): (look for the version numbers in the package.json file of your project and paste your dependencies and devDependencies here)

dependencies: "@nativescript/appversion": "2.0.0", "@nativescript/core": "7.3.0", "@nativescript/webpack": "4.1.0", "moment": "2.29.1", "moment-timezone": "0.5.33", "nativescript-modal-datetimepicker": "2.1.5", <-- (I tried lower versions as well, like 2.0.1) devDependencies: "@nativescript/android": "7.0.1", "@nativescript/ios": "7.2.0",

CLI: 7.2.1

Please, tell us how to recreate the issue in as much detail as possible.

Describe the steps to reproduce it.

  1. Open the sample app
  2. Tap 'Pick a Date'
  3. Tap 'Cancel' or 'Done'
  4. If the issue does not occur, close the app completely and go to step 1

Is there any code involved?

  • provide a code example to recreate the problem
  • (EVEN BETTER) provide a .zip with application or refer to a repository with application where the problem is reproducible.

enich-dev avatar Apr 15 '21 20:04 enich-dev

@davecoffin Any help would be appreciated as this will heavily impact our app. Thank you.

enich-dev avatar Apr 19 '21 16:04 enich-dev

Do you have a catch block in your code? like .catch( after .then? I removed it and no longer having the crashing error.

pandabuilt avatar Apr 21 '21 20:04 pandabuilt

@enich-dev did this work for you?

pandabuilt avatar Apr 24 '21 14:04 pandabuilt

I tried @pandabuilt's suggestion and it didn't work, the app still crashes when tapping the Done button on the date picker modal even when the catch block is removed. Here is the code:

export function showDatePicker(title: string, value: Date): Promise<Date> {
    const picker = new ModalDatetimepicker();
    return picker
        .pickDate({
            title: title,
            theme: 'light',
            startingDate: value
        })
        .then(result => {
            console.log('in then, result: ', result);
            return result ?
                new Date(result.year, result.month - 1, result.day) : null;
        });
}

Interestingly, it doesn't make it into the then or catch functions when it crashes, nor does it show any errors in the logs. It simply quits the app. Then if I reopen the app, the date picker works fine. Forcing a rebuild of my app causes it to error again when I tap the Done button in the date picker modal.

Some observations that I had that contradict others' experiences in this ticket:

  1. I can observe this error only when tapping the Done button. Tapping the Cancel button works fine for me every time.
  2. I can reproduce this error not just on iOS 14.4 but also iOS 13.2, so it doesn't seem to be specific to 14.4.
  3. It works fine on Android, no crashes.

Was anyone able to get past this error?

justintoth avatar Apr 24 '21 21:04 justintoth

Nevermind, I stand corrected. It's reopening the app that works not my removal of the catch block.

pandabuilt avatar Apr 27 '21 14:04 pandabuilt

i have the same error...

AquilesOliveiraDev avatar Apr 28 '21 01:04 AquilesOliveiraDev

Hey all, unfortunately my team and I did not have time to dig into this further and we decided to use NativeScript's own datetimepicker that can be found here. In doing so, we are no longer seeing crashes. I hope this will help others as well. Thanks.

enich-dev avatar Apr 28 '21 15:04 enich-dev

i have the same problem.

cristiandaulisio avatar Jul 28 '21 10:07 cristiandaulisio

@Atomico001 As @enich-dev suggested, switch to NativeScript's datetimepicker. It works much better.

justintoth avatar Jul 28 '21 11:07 justintoth

@Atomico001 As @enich-dev suggested, switch to NativeScript's datetimepicker. It works much better.

Thanks you, i have a problem... other plugin ask me the "context", i tried application context but doesn't work.. any idea?

cristiandaulisio avatar Jul 28 '21 12:07 cristiandaulisio