Bug 38819 - await SavePropertiesAsync(); in "OnSleep" crashed Android app
Summary: await SavePropertiesAsync(); in "OnSleep" crashed Android app
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.0.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Paul DiPietro [MSFT]
Depends on:
Reported: 2016-02-16 21:44 UTC by Erik Renaud
Modified: 2017-06-19 21:00 UTC (History)
5 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Erik Renaud 2016-02-16 21:44:16 UTC
I put an 
await SavePropertiesAsync();
in my Spp
        protected async override void OnSleep()

When changing activity on android, the app crashed with a sharing violation on isolated storage file property store forms.tmp

I also had the error when I forced a SavePropertiesAsync().Wait() after changing a two properties beacuase the one save overlapped with another.

Could you please add locking so that no two "SaveProperties" call that occur simultaneously crashes the app.
Comment 1 Erik Renaud 2016-02-16 21:46:07 UTC
Stack trace as transmitted to HockeyApp

02-16 16:37:45.076 D/HockeyApp( 2017): System.IO.IOException: Sharing violation on path PropertyStore.forms.tmp
02-16 16:37:45.076 D/HockeyApp( 2017): 	at System.IO.FileStream..ctor(System.String_path__FileMode_mode__FileAccess_access__FileShare_share__Int32_bufferSize__Boolean_anonymous__FileOptions_options.args:1337)
02-16 16:37:45.076 D/HockeyApp( 2017): 	at System.IO.FileStream..ctor(System.String_path__FileMode_mode__FileAccess_access__FileShare_share__Int32_bufferSize__Boolean_isAsync__Boolean_anonymous.args:1337)
02-16 16:37:45.076 D/HockeyApp( 2017): 	at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(System.String_path__FileMode_mode__FileAccess_access__FileShare_share__Int32_bufferSize__System.IO.IsolatedStorage.IsolatedStorageFile_isf.args:1337)
02-16 16:37:45.076 D/HockeyApp( 2017): 	at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(System.String_path__FileMode_mode__System.IO.IsolatedStorage.IsolatedStorageFile_isf.args:1337)
02-16 16:37:45.076 D/HockeyApp( 2017): 	at com.slingboards_lab.daytickler.edStorage.IsolatedStorageFileStream:.ctor(string_System.IO.FileMode_System.IO.IsolatedStorage.IsolatedStorageFile.args:1337)
02-16 16:37:45.076 D/HockeyApp( 2017): 	at System.IO.IsolatedStorage.IsolatedStorageFile.OpenFile(System.String_path__FileMode_mode.args:1337)
02-16 16:37:45.076 D/HockeyApp( 2017): 	at com.slingboards_lab.daytickler.edStorage.IsolatedStorageFile:OpenFile(string_System.IO.FileMode.args:1337)
02-16 16:37:45.076 D/HockeyApp( 2017): 	at com.slingboards_lab.daytickler.Xamarin.Forms.Platform.Android.Deserializer+<>c__DisplayClass2_0.<SerializePropertiesAsync>b__0(.args:1337)
02-16 16:37:45.076 D/HockeyApp( 2017): 	at System.Threading.Tasks.Task.InnerInvoke(.args:1337)
02-16 16:37:45.076 D/HockeyApp( 2017): 	at System.Threading.Tasks.Task.Execute(.args:1337)
Comment 2 Paul DiPietro [MSFT] 2016-12-20 20:35:29 UTC
If this is still occurring for you on the latest stable, can you provide a reproduction? Thank you in advance for any assistance in investigating.
Comment 3 Chris King 2017-06-19 17:22:06 UTC
Assigned to you as you were last to request additional info.
Comment 4 Paul DiPietro [MSFT] 2017-06-19 21:00:44 UTC
Because we have not received a reply to our request for more information we are closing this issue. If you are still encountering this issue, please reopen the ticket and attach a project that demonstrates the issue.