We're sorry GroupDocs doesn't work properply without JavaScript enabled.

Free Support Forum - groupdocs.com

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=(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tU=()+15  Aspose.Pdf.Devices.ImageDevice.#=z_zmK4tU=(Aspose.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.