PHPickerViewController shows error every second attempt to display gallery

Our team has implemented PHPickerViewController to allow multiple photos to be selected. It works fine in the simulator but when tested on actual iPad we have this strange behaviour. The first time the gallery is displayed it works fine. If we try and display the gallery again it displays a window with this message “Unable to Load Items - [Try Again]”. If I tap [Try Again] or if I use our Gallery button it does display the gallery. And it keeps cycling through this behaviour. ie. every second attempt to display the gallery leads to the “Unable to Load Items” window.  

Every time we display the gallery we dismiss the old instance and create/initialize a new instance of the controller. Our code is written in objective-c…

-(void)initPHPickerController 
    {
      [self dismiss];
      mPHPickerController = nullref;
    
      PHPickerConfiguration *config = [[PHPickerConfiguration alloc] init];
      config.selectionLimit = 0; // 0 represents no selection limit.
      config.filter = [PHPickerFilter imagesFilter];
    
      config.preferredAssetRepresentationMode = PHPickerConfigurationAssetRepresentationModeCurrent;
    
      PHPickerViewController *pickerViewController = [[PHPickerViewController alloc] initWithConfiguration:config];
      pickerViewController.delegate = self;
    
      mPHPickerController = pickerViewController; 
    }


    - (void)dismiss 
    {
      if (mPHPickerController)
      {
        [+mPHPickerController dismissViewControllerAnimated:YES completion:nil];
      }
      ...
    }

Any suggestions on how to fix this ?

I have seen a post on stackoverflow that this may be a bug in iOS.