Page 1 of 1

Access Vialoation on Webserver

Posted: Fri Sep 19, 2014 4:03 pm
by 16567896
Delphi XE5
TChart Pro v2014.11.140512 32bit VCL

Hi,

I am facing a strange Problem. When I try to create a Chart in the context of a webserver application I receive an Access Violation in VCLTee.TeeProcs. The last line I followed the error is in that unit exactly at that line

Code: Select all

FChartBounds:=InternalCanvas.InitWindow(UserCanvas,FView3DOptions, PanelColor(Color),
                                            FView3D, UserRect);
which is in the procedure "TCustomTeePanel.Draw".

When I run the same code in the context of an offline app the Access vialoation doesn't happen. Could this have something to do with the fact that I do not have a parent window in a webserver application or do you use GDI+ routines which may cause the problems?

With v2013 everything is ok. So I think I have to again switch back to that Version!

Regards
Markus

Re: Access Vialoation on Webserver

Posted: Mon Sep 22, 2014 8:13 am
by yeray
Hi Markus,

Is it possible for you to isolate the problem in a new simple application you can send us so we can reproduce the problem here?

You can try moving back to GDI but, without the simple application mentioned above, it will be difficult to find what change affected this.
Also, can you please precise what v2013 release did work fine for you? 2013.08 or 2013.09?

Re: Access Vialoation on Webserver

Posted: Mon Sep 22, 2014 10:47 am
by 16567896
Hi Yeray!

making an example project that behaves like mine schould be difficult and most of all too time expensive for me at that time. But I analysed the problem further and I found the reason why or better when the error occurs. If I do not load a tee file into my chart object the error occurs but if so it doesn't. When I compile the same project code in Delphi XE2 where I am using TeeChart Pro v2012.05.120327 32bit VCL (I was wrong it was not 2013) the fact that I don't load a tee File to my Chart object doesn't matter. Everything is fine. But not with the TeeChart Pro v2014.11.1405512 Code. So anyhow there seems to be a difference in the behavior of TChart. I didn't analyse deeper because now I can solve my problem by allways loading a tee file to my Chart object. That's how my code looks at thís point:

Code: Select all

    GlobalRPChart := TChart.Create(nil);

    //Load a tee File if we have one
    if FileExists(ChartFile) then LoadChartFromFile(TCustomChart(GlobalRPChart), ChartFile)
    else begin
      GlobalRPChart.Height := GlobalRPTable.RPImage.Height;
      GlobalRPChart.Width := GlobalRPTable.RPImage.Width;
    end;
Regards
Markus

Re: Access Vialoation on Webserver

Posted: Tue Sep 23, 2014 8:36 am
by yeray
Hi Markus,

It's difficult to find the root of the problem without reproducing it here in a simple example.
Anyway, I'm glad to hear you found a way to make it work fine.

Re: Access Vialoation on Webserver

Posted: Wed Oct 01, 2014 10:22 am
by 16567896
Hi Yerray!

Well after everything was ok for me because I found a solution for the problem I downloaded the latest Version from September, 24th (v2014.12.140923). In an offline context everything went fine but now I compiled my project again in a webserver application and it again crashes! Now it crashes on a very early state exactly where I do this:

Code: Select all

GlobalRPChart := TChart.Create(nil);
So it crashes anywhere in the TChart universe! Now I switched back to v2014.11.140512 and everything works fine again. Ist really frustrating for me because whenever I made an update since the 2012 Version I had problems. Making the next update old problems were solved but new ones appear. Because the error appears only in a webserver enviroment could this have something to do with GDI Plus again? Did you make a change that forces GDI Plus right at the moment when the TChart.Create method is called? GDI Plus causes problems in webserver enviroments. If so I would see no chance to build a work around for the problem because I must first call the create method.

Regards
Markus

Re: Access Vialoation on Webserver

Posted: Thu Oct 02, 2014 7:30 am
by yeray
Hi Markus,
MHotz wrote:Well after everything was ok for me because I found a solution for the problem I downloaded the latest Version from September, 24th (v2014.12.140923). In an offline context everything went fine but now I compiled my project again in a webserver application and it again crashes! Now it crashes on a very early state exactly where I do this:

Code: Select all

GlobalRPChart := TChart.Create(nil);
So it crashes anywhere in the TChart universe! Now I switched back to v2014.11.140512 and everything works fine again. Ist really frustrating for me because whenever I made an update since the 2012 Version I had problems. Making the next update old problems were solved but new ones appear. Because the error appears only in a webserver enviroment could this have something to do with GDI Plus again? Did you make a change that forces GDI Plus right at the moment when the TChart.Create method is called? GDI Plus causes problems in webserver enviroments. If so I would see no chance to build a work around for the problem because I must first call the create method.
I'm sorry to hear you find so much problems when updating TeeChart.

Have you tried setting GDI as the default canvas for new charts?
You can set it at design time. This action changes this key in the registry, that is the key evaluated when a new chart is created.

Re: Access Vialoation on Webserver

Posted: Thu Oct 02, 2014 9:55 am
by 16567896
Hi Yeray,

thank you for your reply! The hint for the registry key was helpfull. But I cannot Change registry keys on webservers! So I searched the source code for the position where the DefaultCanvas was set. I found this entry in TeeProcs:

Code: Select all

  // Setting TeeDefaultCanvas:='' will not look at registry, and will not
  // use VCL GDI+ 
So I changed the following line also in TeeProcs:

Code: Select all

  TeeDefaultCanvas:={$IFDEF FMX}''{$ELSE}'TGDIPlusCanvas'{$ENDIF};
to

Code: Select all

  TeeDefaultCanvas:={$IFDEF FMX}''{$ELSE}''{$ENDIF};
Then I recompiled the whole package and indeed that solved the problem. Now my charts also work on a webserver! But with the next update I have to remember that change because otherwise I will face the problem again. So this seems to be an intermediate solution but not a steady one. It would be great if you and your colleagues would consider a solution that avoids such a work around.

Thanks and Regards
Markus

Re: Access Vialoation on Webserver

Posted: Thu Oct 02, 2014 11:32 am
by yeray
Hi Markus,
MHotz wrote:

Code: Select all

  TeeDefaultCanvas:={$IFDEF FMX}''{$ELSE}''{$ENDIF};
Then I recompiled the whole package and indeed that solved the problem. Now my charts also work on a webserver!
I didn't recall you had the sources and thus that was an option for you. Great you found that!
Actually you could simply leave:

Code: Select all

  TeeDefaultCanvas:='';
MHotz wrote:But with the next update I have to remember that change because otherwise I will face the problem again. So this seems to be an intermediate solution but not a steady one. It would be great if you and your colleagues would consider a solution that avoids such a work around.
Without a simple example project we can run as-is to reproduce the problem here it's difficult for us to provide a final solution.

As a more solid workaround, instead of editing TeeProcs and recompiling after each TeeChart release, you could make sure TeeProcs unit is in the uses section of any unit where you create a TChart, and add this line before creating any TChart:

Code: Select all

  TeeDefaultCanvas:='';
Ie:

Code: Select all

uses Chart, TeCanvas, TeeGDIPlus, TeeProcs;

var Chart1: TChart;

procedure TForm1.FormCreate(Sender: TObject);
begin
  TeeDefaultCanvas:='';

  Chart1:=TChart.Create(Self);
  Chart1.Parent:=Self;

  Caption:='We are on ';
  if Chart1.Canvas is TGDIPlusCanvas then
    Caption:=Caption + 'GDIPlus'
  else
    Caption:=Caption + 'GDI'
end;

Re: Access Vialoation on Webserver

Posted: Thu Oct 02, 2014 3:10 pm
by 16567896
Hi Yeray,

thank's for that hint! That's indeed a better solution and avoids failing again after an update. Hope this will work for me and also I hope that I have now a stable version of TChart for my project.

Regards
Markus

Re: Access Vialoation on Webserver

Posted: Fri Oct 03, 2014 7:07 am
by yeray
Hi Markus,
MHotz wrote:thank's for that hint! That's indeed a better solution and avoids failing again after an update. Hope this will work for me and also I hope that I have now a stable version of TChart for my project.
I hope it too!
What I can guarantee is that we'll be here trying to help in everything within our possibilities.