Threading Issue

Hi,

I’ve come across an issue whereby is we have something around 3-8 concurrent conversation of files, some of them become stuck indefinitely, and their threads cannot be cancelled. I’ve tried the update, tried cancel tokens, but nothing helps outside of restarting the microservice.

Here’s part of the of the stack trace starting from the GroupDocs method. I am using GroupDocs.Viewer.Viewer.View:

System.Collections.Generic.Dictionary`2[[System.Single, mscorlib],[System.__Canon, mscorlib]].FindEntry(Single)+ad  System.Collections.Generic.Dictionary`2[[System.Single, mscorlib],[System.__Canon, mscorlib]].ContainsKey(Single)+c  #=zFyUWyp$g3LmUVhLdIngo6BizT4nbuAXklw==.#=zz7b9xP0_k_4m(System.String, System.Object)+100  #=zdcZDrO$CfWmPF8bE9CCtifupe9RhNfPjBcErmn5xdPYq.#=zw1s56ds=(System.Collections.Generic.List`1<System.Object>, Boolean)+69  #=zYa_kN$0aM62IUOhkbAze3rQBlDXpJhh1VpR06Ea6q4ce.#=zapx_8Qohs1N1(System.String, System.Collections.Generic.List`1<System.Object>, System.Collections.Generic.List`1<#=zSc2zND9faB2l1cyMlh71ruoixXuX_PgWTo$0MCkWox0p>, #=zW0sGGCtV48cpUr2xJB9QfQnc6li8NHKYUL2JsIApjjUj)+70  #=zYa_kN$0aM62IUOhkbAze3rQBlDXpJhh1VpR06Ea6q4ce.#=zWrXvPKFpgLNt(#=z9SgYabW0TLL$mgFSEuqJ0lv_LkZzPJdhCQ==, #=zklR7lxUuz8iQbde7HzYawJdEKEqGdG$4pRlD7YNWQJlL, Boolean, Boolean)+6c5  #=zYa_kN$0aM62IUOhkbAze3rQBlDXpJhh1VpR06Ea6q4ce.#=zWrXvPKFpgLNt(#=z9SgYabW0TLL$mgFSEuqJ0lv_LkZzPJdhCQ==, #=zklR7lxUuz8iQbde7HzYawJdEKEqGdG$4pRlD7YNWQJlL)+15  #=zYa_kN$0aM62IUOhkbAze3rQBlDXpJhh1VpR06Ea6q4ce.#=zoSyPaRg=(#=z5SX9BYAEnkTXwv6uQ4a0DddJTbdC, #=z9SgYabW0TLL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Pdf.Page)+b1  Aspose.Pdf.Devices.PngDevice.Process(Aspose.Pdf.Page, System.IO.Stream)+19    .    (Int32, GroupDocs.Viewer.Interfaces.IPageStreamFactory)+5c   
  .(Int32[],   , GroupDocs.Viewer.Options.PngViewOptions, GroupDocs.Viewer.Interfaces.IPageStreamFactory)+152   
  .    (System.Func`3<GroupDocs.Viewer.Options.ViewOptions,System.Threading.CancellationToken,  >, GroupDocs.Viewer.Options.ViewOptions, System.Threading.CancellationToken, Int32[])+114    .(System.Func`3<GroupDocs.Viewer.Options.ViewOptions,System.Threading.CancellationToken,  >, Int32[], GroupDocs.Viewer.Options.PngViewOptions, System.Threading.CancellationToken)+1f2    .    (System.Func`3<GroupDocs.Viewer.Options.ViewOptions,System.Threading.CancellationToken,  >, GroupDocs.Viewer.Options.ViewOptions, System.Threading.CancellationToken, Int32[])+9a  GroupDocs.Viewer.Viewer.View(GroupDocs.Viewer.Options.ViewOptions, System.Threading.CancellationToken, Int32[])+9f

It looks like it gets stuck in FindEntry of the dictionary, which is not controlled code of Group Docs and looks like could not be cancelled by token cancellation.

Here’s a snippet of the code i’m using:

using (var stream = new MemoryStream(inputBytes))

{

var logger = new GroupDocsLogger(Environment.MachineName.ToString());

var viewerSettings = new ViewerSettings(logger);

using (var viewer = new Viewer(stream, new LoadOptions { FileType = FileType.DOCX }, viewerSettings))

{

var pageStreamFactory = new MemoryPageStreamFactory(pages);

var viewOptions = new PngViewOptions(pageStreamFactory)

{

DefaultFontName = ""

};

if (req.Query.ContainsKey("allPages"))

{

viewer.View(viewOptions);

} else

{

viewer.View(viewOptions, pageNumbers);

}

}

}

Thank you for the help.

@mdraisey

Thank you for adding the code you’re using. Can you please confirm that the issue is happening when you converting DOCX files?

Hi @vladimir.litvinchik. It happens more frequently with PDF files.

@mdraisey

Got it, thank you. It’s essential for us to know which file formats are related since we’re using different rendering engines for different file formats. We’ll try reproducing this issue on our side and share the results here.

@vladimir.litvinchik I’ve purchased paid support. Can this please be moved across?

@mdraisey

This issue will be handled with a higher priority. The issue ID for reference is VIEWERNET-3992.

1 Like

@mdraisey

What version of GroupDocs.Viewer you are using?
Do you know which (maybe some specific) files are stuck in processing?

I tried to reproduce your issue and attached sample application:
TestCancelApp.zip (2.6 MB)
I think in your file set, GroupDocs.Viewer met file which stuck if you can find that file it will be good for reproducing the issue.

@mdraisey
Did you try the attached application?

Hi @mikhail.evgrafov.aspose,

I have. I have recreated the issue - console app attached and a video of the runs can be seen here - Recordit: Record screencasts fast & free! with GIF Support!

The file I used was ~15mb in size. Please let me know if you need it as it can’t be uploaded here.

Thanks

@mdraisey

Yes, we need the file. Might you to upload it somewhere?

@mdraisey

File required to reproduce an issue.

@mikhail.evgrafov.aspose Link to file added to paid for support ticket #004499

@mdraisey

The folder that you shared is empty. Might you reupload the file?

@mikhail.evgrafov.aspose the file and source code have been added to the share. I had to seek permission to share the file, hence the delay

1 Like

@mdraisey thank you, the file will be checked.

@mdraisey
The issue is reproduced, and your file is valid: no issue if threads count <= 3.
Now we can analyze the issue deeper to fix it.

Thank you for the update @mikhail.evgrafov.aspose

You are welcome!