Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Fix to - Only one operation can be active at at time #598 #649

Merged
merged 9 commits into from
May 23, 2019

Conversation

vagrawal1986
Copy link
Contributor

Fixes # .

  1. src/Media.Plugin/Android/MediaImplementation.cs
  2. src/Media.Plugin/Android/MediaPickerActivity.cs
    Changes Proposed in this pull request:
    Following scastria comment -

#598 (comment)

"The cause is pretty simple. The media picker uses TaskCompletionSource to turn a callback driven API into Task async/await style. but the code adds a check to make sure that only 1 TaskCompletionSource is active at one time. "
"So whether you click the button twice or do my workflow, in both cases TaskCompletionSource is not null the second time and the exception is thrown."

If we null out the completionSource onDestry of the MediaPicker activity, we can get rid of the bug

changed the variable "completionSource" scope to public static, to access it from MediaPickerActivity
Following Scastria comment from the bug -
jamesmontemagno#598 (comment)
If we null out the completionsource on sleep, which will call OnDestry to the media Activity, it fixes the issue
@vagrawal1986 vagrawal1986 reopened this Jan 3, 2019
@vagrawal1986
Copy link
Contributor Author

vagrawal1986 commented Jan 29, 2019

@motoko89 - Here are the steps for this -
This bug is hitting us too but with a different workflow:

  1. Launch app
  2. start media picker
  3. click home button
  4. resume app by clicking icon on phone desktop (if you use the task switcher, it works)
  5. app resumes but media picker is gone
  6. start media picker
  7. crash with "Only one operation can be active at at time"

Now as soon as you click the hime button, destroy on the Media activity will get called as its not the Main activity in my case. Main activity is my App, where I am using the Media plugin, which has a MediaPickerActivity.

@ghost ghost assigned jamesmontemagno Feb 9, 2019
@ghost ghost added the in-progress label Feb 9, 2019
@jamesmontemagno
Copy link
Owner

There were a lot of changes in the multi-select gallery part, will need to resolve some conflicts or make a new PR here

@vagrawal1986
Copy link
Contributor Author

@jamesmontemagno
Thanks for looking into this. All conflicts resolved, would greatly appreciate if this can be merged.
Thanks
Also,
I am very new to Github community and this is my first pull request, so pardon any silliness :)

Applied same changes for TaskCompletionSource<List<MediaFile>> completionSourceMulti;
We need to also null the completionSourceMulti.completionSource as we did for MediaImplementation.completionSource
@Trevonious
Copy link

@vagrawal1986 Do you think this fix would apply to the issues with clicking outside the popup in iOS (see #666)? It looks like the original author of the multi-select feature was seeing the same issue as me, but it seems he thought it was handled (#598 (comment)).

@vagrawal1986
Copy link
Contributor Author

@Trevonious
The fix I put in only caters droid only as I did not face any issue with iOS at least before multi-select. I have not investigated clicking outside issue on iOS for multi select. But I think this fix should handle the android part of the bug.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants