Aspose.Slides for dotnet not threadsafe?

Hi!

I am experimenting thread freeze while saving PresentationEx (see ThreadJob1) or exceptions while modifying Shape (see ThreadJob2) when using aspose.slides in multithreading environment :

public void ThreadJob1()
{
// saving pptx
PresentationEx presex = new PresentationEx(path + filename);
for (int i = 0; i < count; i++)
{
MemoryStream stream = new MemoryStream();
presex.Save(stream, SaveFormat.Pptx);
System.Diagnostics.Trace.WriteLine(Thread.CurrentThread.ManagedThreadId + “:” + i);
}
}

public void ThreadJob2()
{
// modifiy ppt
Presentation pres = new Presentation(path + filename);
for (int i = 0; i < count; i++)
{
foreach (Shape shape in pres.Slides[0].Shapes)
{
shape.X += 10;
shape.Y += 10;
Thread.Sleep(0);
}
System.Diagnostics.Trace.WriteLine(Thread.CurrentThread.ManagedThreadId + “:” + i);
}
}

Please see attached code

This is very important : Is Aspose.Slides Really Threadsafe ?

Thanks

Hi Pascal,


Thanks for sharing the sample code. Can you please provide the sample presentation used for our investigation. I will try to reproduce the issue on my end and may need to add the issue in our issue tracking system for further investigation.

Many Thanks,

Ok, here are the presentations I used.

With pptx, crash (ThreadJob3, see under) or freeze (ThreadJob1, same as yesterday) will append quickly : several hundreds of iterations with 16 threads on my core i7 CPU.

With ppt, is it much more unfrequent maybe because ppt api is faster than pptx.

Please note : All that append outside debugger.


Here the function for multislide presentation :

public void ThreadJob3()
{
// modifiy pptx
PresentationEx presex = new PresentationEx(path + filename);

for (int i = 0; i < count; i++)
{
foreach (SlideEx slide in presex.Slides)
{
foreach (ShapeEx shape in slide.Shapes)
{
// reading seems to be ok
float x = shape.X;
float y = shape.Y;
// modifying leads to exception
shape.X = x + 10;
shape.Y = y + 10;
}
}
System.Diagnostics.Trace.WriteLine(Thread.CurrentThread.ManagedThreadId + “:” + i);
}
}

Thanks

Hi,


I have worked with the sample code shared by you and have generated the sample application. I have worked over ThreadJob1, ThreadJob2 and ThreadJob3. I have not been able to observe any issue on my end by using all three mentioned thread methods. Importantly, there is no confliction in thread definition methods as well. In each thread you have accessed the instance of Presentation or PresentationEx object that is loading the presentation. This cause the separate instance for every Presentation or PresentaionEx and loads a separate copy of presentation in Document Object Model in every thread instance.

After my investigation on Windows 7 x64 with 8 GB ram, I have not been able to observe any exception or freezing issue. Can you please share what did you actually meant by freezing. I have attached the sample application for your reference as well.

Many Thanks,

Thanks for your response.

By “freezing” I mean that while the program is still running and of course before loops are finished, CPU is at 0%.

Here is a screenshot of debugger after attaching it to the process (ThreadJob1Stucked.jpg).

I also took screenshots after program crash while running the ThreadJob3 scenario:
ThreadJob3Exception01.jpg, ThreadJob3Exception02.jpg (Win7 x64, core i3; 12Go)
and ThreadJob3Exception02WinXP.jpg (Win XP 32 bits core 2 duo 4Go).

Hi,


Thanks for sharing your feedback. As I shared with you in my last post that I have not been able to reproduce the issues on my end with 8GB Core i7 machine installed with Windows x64. Secondly, in your threads there is not common entities used and every thread is separate instance. However, based on feedback shared by you, I am creating an issue with ID SLIDESNET-33849 as investigation so that our development team may investigate the issue further on their end and see whether they can reproduce it or not. I will share the findings with you as soon as our development team will schedule and investigate the issue.

We are sorry for your inconvenience,

Hi !
Thanks for considering this issue.

This is very important fior our project, we are currently blocked in the development as multithreading and scalability is required.

If you want to reproduce these bugs, please launch the exe outside the debugger, monitor the activity with DebugView and… wait a few minutes.

Issue has occured on every machine and OS : Core duo, i3, i7…

Thanks for your attention.

Hi,


Thanks for sharing the further information. I like to share that your issue has been scheduled for investigation during week 51/2012. We will share the further information with you once investigation will be completed by our development team.

Many Thanks,

Hi

week 51/2012 has gone…

Is there any news about these issues ?

Shall we consider that Aspose.Slides is definitively NOT threadsafe ?

Regards

Hi,


Please accept my sincere apologies for the inconvenience on your end. I have verified from our issue tracking system and like to share that owing to pending issues and product releases the issue have not been resolved yet. In fact it has been moved to Week 05/2013 for investigation. I am sorry for your inconvenience but will really appreciate if you may please hold on for the requested time and our development team may carry on their investigation. I will add request in our issue tracking system as well for as soon as possible investigation of the issue.

Many Thanks,
Mudassir:
Hi,

Please accept my sincere apologies for the inconvenience on your end. I have verified from our issue tracking system and like to share that owing to pending issues and product releases the issue have not been resolved yet. In fact it has been moved to Week 05/2013 for investigation. I am sorry for your inconvenience but will really appreciate if you may please hold on for the requested time and our development team may carry on their investigation. I will add request in our issue tracking system as well for as soon as possible investigation of the issue.

Many Thanks,


Hello,
Ok, we are now Week 7... Anything new ?

Hi,


I have verified from our issue tracking system and like to share that the issue shared is still in progress and I have requested our development team to share the updated status. As per our issue tracking system the issue was moved to Week 07 owing to some internal limitations. Our development team is likely to complete their investigation by this week end. However, I am still awaiting response from our development team and will update you as soon as it will be shared by them.

We are sorry for your inconvenience,

Hi,


Our development team has completed their investigation on the issue. As I shared with you earlier in this post that I have not been able to reproduce the issue specified, the same response has been shared by our development team and they have failed to reproduce the issue on their end. They have tested Aspose.Slides for .NET 7.1.0 on Win 7 x64, i5, 4Gb Ram.

We are sorry for your inconvenience,

Hello

I have made more stressing tests and you/we have a real problem of concurrent access somewhere near the calls to System.Drawing.dll.

Please note I am talking about the “save” issue, ie saving a Presentation or PresentationEx (ThreadJob0 ot ThreadJob1 in the attached source code).

Your development team should have seen it.

- Sometimes all threads hang, sometimes all but one and memory usage grows like crazy, sometimes an exception is thrown…
- It seems it happens much more often on a fast desktop corei7 than on the “old” laptop core2.
- It happens on a VM (on the same computer), provided that the VM uses more than one processor.

If you want to reproduce this issue (and I am sure you will) please note :

- Use a high speed CPU
- Use more threads than available processors/cores
- Use parameters like they are in the source code, just change the path.
- Save to pdf
- And Please let the test program run at least one minute or two.


Unfortunately, as you know, the customer’s servers are generally high power machines and we have to be robust enough…


Thanks for reading.

Hi,


Thanks for sharing the additional details. I have generated the sample application based on scenario shared. I have also shared the my system information with you as well. I have not been able to observe the issue and have shared the output.txt as well for your reference in the attached zip file. I have also shared the details with our development team as well in this regard and will share the feedback with you as soon as response will be shared by them.

Many Thanks,

Hi, thanks for your tests and your answer.

Here are some news :

I have tested on different VM :

- Win7 32 fr
- Win7 64 fr
- Win7 64 en
- Win8 32 fr

The issue occurred only in 64bit version and does not seem to be language related…


Here is what I discovered :

If I generate in “x86”, it’s ok everywhere
If I generate in “x64” or “Any CPU”, it fails on x64 platforms.

Unfortunately that’s a half good new because we lose the benefit of memory size and as you know sometimes Aspose.Slide is very very memory consuming…


Another thing I discovered is that I am using Microsoft Visual Studio 2010 Professional SP1 (Version 10.0.40219.1 SP1Rel), and it seems that you are using VS 2008.
So I generated on another computer with VS2005… and it still crash the same way :frowning:

Then I tested with your exe and… still crash too!


Have you or your team ever heard about such problem ?
Is there something I am wrong with ?
What can I do to check compilation/installation process? (Of course I read the doc)


Thanks in advance


Regards

Hi,


Thanks for your further investigation. I like to share that our development team is also observing the issue and I have updated the issue status with new information shared by you.

I also don’t feel that the issue shared is language related. Secondly, I have generated and shared a Visual Studio 2010 application for your kind reference this time. I have used Aspose.Slides for .NET 7.1.0 ClientProfile 4.0 assembly for my investigation. Earlier, I used Aspose.Slides for .NET 7.1.0 net 2.0 assembly. Also, I am using Windows 7 x64 installed on a Core i7 machine. I have performed every testing so far in this environment and have never been able to reproduce the issue on my machine. However, as I have said earlier, that I have also added the details shared by you for our development team so that they may also try to reproduce on their end.

In my humble opinion the issue is not related to x64 but our development team will share their eventual response in this regard. I have also attached the output file and Visual studio version info image for your kind reference.

Many Thanks,

Thanks for your test with VS2010

The exe in your zip is “x86” so it run ok here.

After regenerate in “AnyCPU” and when lauched in a command prompt window it crashes like the others as you can see in the log attached.

Regards.



NB:
“Le paramètre n’est pas valide” is “invalid parameter”
“Tentative de lecture ou d’écriture de mémoire protégée. Cela indique souvent qu’une autre mémoire est endommagée.” is “Attempted to read or write protected memory. This is often an indication that other memory is corrupt.”




Hi,


Thanks for your further feedback. I have observed the log file shared. Can you please kindly share the complete sample application as shared by me with which you have obtained the log file. I will try to use the same application on my end.

Many Thanks,

Hello,

This is the same application I sent you and you sent me back yesterday, compiled for .NET 4.0.

Regards