We've figured out how this issue happened at JLCPCB and I try to explain it in this post.
Octagonal pads and vias are very common in Eagle. When Eagle outputs Gerbers, an aperture macro called OC8 is used to represent these pads and vias.
%AMOC8* <1>
5,1,8,0,0,1.08239X$1,22.5* <2>
%
%ADD10C,0.00700*%
%ADD11C,0.00300*%
%ADD12R,0.47244X0.19685*%
%ADD13OC8,0.06000*% <3>
- Start to define the OC8 macro, AM = Aperture Macro
- The contents of OC8, primitive code 5 means Polygon, 1 means Exposure On, 8 means octagon, 0,0 is the x/y coordinate of center point, 1.08239X$1 means Diameter, 22.5 is the rotation angle.
- This line defines an aperture D13, it uses macro OC8.
This figure below is from The Gerber File Format Specification November 2013 Revision J1
https://web.archive.org/web/20130630231317/http://www.ucamco.com:80/en-us/downloads.aspx, page 92, which is about primitive code 5 (polygon).
Note: In newer Eagle versions (such as 9.6.2), the octagonal pads are output as standard Regular polygon, macro OC8 is still in the file, but it not refered anymore. Here's a related thread
https://forums.autodesk.com/t5/eagle-forum/gerber-regular-polygon-add-lt-nr-gt-p-vs-add-lt-nr-gt-oc8/td-p/7864702%ADD32P,1.649562X8X112.500000*%
In the CAM tool which is used to process the Gerbers, there is a parameter called: xxx_set_octagon_rot, it has two options:
* no - starting rotation angle of an Octagon = 22.5 (default)
* yes - set it to 0
Now, if this xxx_set_octagon_rot = No:
It means "starting rotation angle of an Octagon = 22.5 (default)", we can know its starting rotation angle, it's like this:
Because OC8 has a 22.5 parameter, so when the CAM reads in the Gerbers, all octagonal pads will be rotated 22.5 degrees (the right one in the above figure will be used as the template), and we get the wrong angles as the users reported in this thread.
If this xxx_set_octagon_rot = Yes:
"yes" (set it to 0): This is the same with the definition in Gerber spec, in this case, one vertex is on the horizontal axis x. When the CAM tool reads in the Gerbers, it just rotate octagonal pads by 22.5 degrees, this is just the rotation angle in Eagle and customers will get the right boards!
On Dec 29 2020, JLCPCB upgraded the system just for this issue, to prevent this issue from happening in the future: Every file will be scanned for these OC8 macros, and the person who processes these Gerbers will be warned that these designs have octagonal pads/vias.
This afternoon (Jan 16, 2021), I placed 20 true orders (Eagle 7.7.0 with the arduino example) in JLCPCB's website and got the process "ok" file, the rotation angle for octagonal pads in all "ok" files are correct.
PS: Don't know how to insert the inline images. I need the help from the moderator. Thanks.