Mediaplugin: Please revert issue 598

Created on 21 Jan 2021  路  3Comments  路  Source: jamesmontemagno/MediaPlugin

Bug Information

Version Number of Plugin: 5.0.1
Device Tested On: Samsung s20, Pixel 3
Simulator Tested On: -
Version of VS: does not matter
Version of Xamarin: does not matter
Versions of other things you are using: does not matter

Steps to reproduce the Behavior

Go to developer settings and enable 'Don't keep activities' option
Implement some code like this:

  var file = await CrossMedia.Current.TakePhotoAsync(
      new StoreCameraMediaOptions
      {
          Directory = StorageDirectoryOption,
          Name = $"{DateTime.Now:yyyy-MM-dd_hhmmss}.jpg",
          PhotoSize = PhotoSizeOption,
          CompressionQuality = CompressionQualityOption,
          ModalPresentationStyle = MediaPickerModalPresentationStyle.OverFullScreen,
      });

  DoSomething(file);    // This Line will never be acheived 

Expected Behavior

await CrossMedia.Current.TakePhotoAsync(...) ends after photo is taken

Actual Behavior

await CrossMedia.Current.TakePhotoAsync(...) never ends after photo is taken

Code snippet

see above

Screenshots

not needed

It looks like this behavior introduced in
https://github.com/jamesmontemagno/MediaPlugin/issues/598#issuecomment-412937648
https://github.com/vagrawal1986/MediaPlugin/commit/0bc5eca822acd2ee123559af54a87d1c19ad2163

with these lines in MediaPickerActvity:

  protected override void OnDestroy()
  {
      if(!completed)
      {
          DeleteOutputFile();
          MediaImplementation.CompletionSource = null;      // THIS
          MediaImplementation.CompletionSourceMulti = null; // THIS
          MediaPicked = null;                               // THIS
      } 
      base.OnDestroy();
  }

According to message from @motoko89, these changes are not fixing anything, but destroys our application.

Any chance to revert these changes?

All 3 comments

I don't think any version of the plugin is compatible if you have "don't keep activities" on.

3.13 perfectly handles this case.

On the other hand, "don't keep activities" simulates situation when there is no memory on the phone, and this case is very common. The Task is never completes and it is very hard to workaround this problem.

Any chance to fail operation Task in such case? We will handle this failing task, and show for example dialog for user?

Anyway, this library is pretty good and we don't want to fork it for our project

are you getting exceptions? maybe i should try/catch it, you can send down a PR.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CesareSoldani picture CesareSoldani  路  6Comments

erossini picture erossini  路  3Comments

manonaga2188 picture manonaga2188  路  5Comments

vinnusaurus picture vinnusaurus  路  6Comments

jamesmontemagno picture jamesmontemagno  路  4Comments