Skip to content

Commit

Permalink
Fix dispose deadlock (hardkoded#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
kblok authored Jun 23, 2018
1 parent 4f76a82 commit 6574f23
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
13 changes: 8 additions & 5 deletions lib/PuppeteerSharp/Launcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class Launcher
private TaskCompletionSource<bool> _waitForChromeToClose;
private bool _processLoaded;
private bool _chromiumLaunched;
private object _isChromeCloseLock = new object();
#endregion

#region Properties
Expand Down Expand Up @@ -389,18 +390,19 @@ private void CleanUp()

private async Task AfterProcessExit()
{
if (IsChromeClosed)
lock (_isChromeCloseLock)
{
return;
if (IsChromeClosed)
{
return;
}
IsChromeClosed = true;
}

if (_options.LogProcess)
{
_logger.LogInformation("Process Count: {ProcessCount}", Interlocked.Decrement(ref _processCount));
}

IsChromeClosed = true;

if (_temporaryUserDataDir != null)
{
await TryDeleteUserDataDir();
Expand All @@ -417,6 +419,7 @@ private async Task KillChrome()
if (!string.IsNullOrEmpty(_temporaryUserDataDir))
{
ForceKillChrome();
await AfterProcessExit();
}
else if (_connection != null)
{
Expand Down
7 changes: 5 additions & 2 deletions lib/PuppeteerSharp/PuppeteerSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<PackOnBuild>true</PackOnBuild>
<PackageVersion>1.0.1</PackageVersion>
<PackageVersion>1.0.2</PackageVersion>
<Authors>Darío Kondratiuk</Authors>
<Owners>Darío Kondratiuk</Owners>
<PackageProjectUrl>https://github.com/kblok/puppeteer-sharp</PackageProjectUrl>
Expand All @@ -12,6 +12,9 @@
<Description>Headless Chrome .NET API</Description>
<PackageId>PuppeteerSharp</PackageId>
<PackageReleaseNotes>
1.0.2
==============
* Fix Dispose deadlocks on ASP.NET MVC
1.0.1
==============
* Fix Chromium downloader on 32bits apps runnning on a x64 platform
Expand Down Expand Up @@ -60,7 +63,7 @@
* PuppeteerSharp.DeviceDescriptors => PuppeteerSharp.Mobile.DeviceDescriptors
* PuppeteerSharp.DeviceDescriptorName => PuppeteerSharp.Mobile.DeviceDescriptorName
</PackageReleaseNotes>
<ReleaseVersion>1.0.1</ReleaseVersion>
<ReleaseVersion>1.0.2</ReleaseVersion>
<SynchReleaseVersion>false</SynchReleaseVersion>
</PropertyGroup>
<PropertyGroup>
Expand Down

0 comments on commit 6574f23

Please sign in to comment.