ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  PHP ChartDirector 7.0 macOS issue
Posted by David Croy on Jun-23-2021 01:20
I have upgraded to 7.0 on my Mac, I get a 500 error when I try to create charts. Even the demo charts don't work. The extension is loaded, it appears to be a font issue. When I try to run testFont("arial.ttf") it crashes.

This on BigSur 11.4. I have tried PHP 7.3 and  and PHP 8.0.

Any ideas?

David

  Re: PHP ChartDirector 7.0 macOS issue
Posted by Peter Kwan on Jun-23-2021 13:42
Hi David,

Is it using Intel CPU or Apple Silicon? Which Apache/PHP server are you using? Is it the one that comes with macOS or from other distribution?

From my testing, the Apache/PHP from macOS does not support third party extensions in Mojave (10.14) and Big Sur (11.x). They have a special flag that marks the PHP as "platform binary" and will only load extensions signed by Apple. For some reasons, macOS Catalina 10.15 does not have such restrictions. All earlier macOS also do not have such restrictions.

To use third party PHP extensions in macOS Big Sur, a third party PHP distribution is needed. If you are using a third party PHP distribution, please let me know what it is. I will immediately download and test myself.

Regards
Peter Kwan

  Re: PHP ChartDirector 7.0 macOS issue
Posted by David Croy on Jun-23-2021 21:00
Peter,
  Thank you for the quick response.
I'm using MAMP Pro version 6.32.
Apache Version 2.4.46
I have tried PHP Version 7.3.24 and 8.0.2
Intel CPU iMac pro.
Since Catalina I have the following fonts sym-linked.
/System/Library/Fonts/Supplemental/Arial Bold.ttf -> /Library/Fonts/Arial Bold.ttf
/System/Library/Fonts/Supplemental/Arial.ttf -> /Library/Fonts/Arial.ttf

I have tried removing the links when debugging the issue with 7.0 and I still have the same issue.

Thank you for your help.
David Croy

  Re: PHP ChartDirector 7.0 macOS issue
Posted by David Croy on Jun-24-2021 06:06
MAMP Pro 6.3.2 not 6.32 Sorry for the possible confusion

  Re: PHP ChartDirector 7.0 macOS issue
Posted by Peter Kwan on Jun-24-2021 16:59
Attachments:
Hi David,

I am able to make it work (see screen shot) and I think I have found out the cause of the problem.

I downloaded the MAMP from the official web site. The one I downloaded reported itself as version 6.3. It has a number of PHP versions and allows for two types of PHP - Module and CGI. The Module works, while the CGI does not work.

The reason is because the CGI implementation is not compatible with the macOS "CoreFoundation". Apple probably considers forking is not secure enough, so it does not permit any forked process to access the "CoreFoundation".

The macOS is built on top of an BSD/UNIX like OS called Darwin. The "CoreFoundation" is the fundamental layer of macOS that is built on top of Darwin. The CGI can work as long as it uses Darwin only, but not other macOS specific features.

ChartDirector 7.0 does use macOS specific features for the fonts. It supports specifying the font using macOS font names (the font names displayed in the macOS Font Book), in addition to using font file names or path names. This triggers the compatibility issue. The exact error as found in the Apache error log is:

=============
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
=============

(The process above refers to the PHP FastCGI process.)

The Module type of PHP does not use forking and does not trigger this issue.

Since we cannot change PHP, to make ChartDirector compatible with the FastCGI PHP on macOS, we may have to remove this macOS feature in ChartDirector 7.0 for PHP.

Regards
Peter Kwan
scrshot.jpg

  Re: PHP ChartDirector 7.0 macOS issue
Posted by David Croy on Jun-24-2021 22:29
Peter,
  Thank you for tracking this down. It works perfectly now.

Out of curiosity Was this a change in ChartDirector 7.0? I have been using ChartDirector for many years running in fast-cgi mode. Actually 6.4 works fine in fast-cgi mode.


Thank you for you help, I really appreciate it.

David Croy

  Re: PHP ChartDirector 7.0 macOS issue
Posted by Peter Kwan on Jun-24-2021 23:11
Hi David,

Yes, it is a new feature in ChartDirector 7.

In all previous versions of ChartDirector, with the exception of the Arial and Times New Roman fonts, all other fonts need to be specified with file names. If the file is a true type font collection, the font index also need to be specified. For example, the Noteworthy Bold font needs to be specified as "noteworthy.ttc|1" (The 2nd font inside the noteworthy.ttc true type font collection).

In many case, in particular for GUI applications (ChartDirector can also be used to write desktop programs), it is desirable to be able to specify the font with the user friendly macOS font name, which is the font you can pick from a font dialog or the font shown in a word processor. Most people only knows the user friend font name, and not about font filename and font index.

In ChartDirector 7, it can accept the user friendly font name. To develop this feature, we need to call several functions in the macOS Core Foundation. But the FastCGI PHP is not compatible with macOS Core Foundation. That's why the issue only occurs in ChartDirector 7 but not earlier versions of ChartDirector.

Since we cannot change PHP, we are considering to remove the user friendly font name support from ChartDirector for PHP, so that ChartDirector for PHP no longer need to use Core Foundation.

Regards
Peter Kwan

  Re: PHP ChartDirector 7.0 macOS issue
Posted by Peter Kwan on Jun-24-2021 23:21
Hi David.

Also, ChartDirector released after Catalina will search subdirectories for the font file, so ChartDirector should be able find fonts in the Supplemental directory.

Regards
Peter Kwan