Speed controlling 12V fan with PWM breaks Photon

All of these schematics are missing a reverse current protection diode to prevent damage from the inductive load of the fan.

From the oscilloscope: looks like you got some capacity on the pin, it can charge quickly but is slower to discharge. Is the pin mode set to output?

Your fan has an internal transistor, so no external one should be needed like suggested above.