Skip to content

Parsing Mac OS X's system_profiler for USB information is a blunderbuss. #4230

Closed
@mralexgray

Description

@mralexgray

I constantly see Arduino.app spawning the process

-+= 00001 root /sbin/launchd
 \-+= 10895 me /.../Arduino.app/Contents/MacOS/Arduino
   \-+- 13588 me /usr/sbin/system_profiler SPUSBDataType
     \--= 13594 me /usr/sbin/system_profiler -nospawn -xml SPUSBDataType -detailLevel full

The system_profiler is notoriously slow, resource hungry, and certainly not the appropriate tool to query the USB subsystem's capabilities. It may be "easy" just to parse some XML that Apple graciously provides.. but that unfortunately does not make it prudent and/or sane to do so.

I see the java code calling out to this API command-line tool in arduino-core/src/processing/app/macosx/Platform.java ...

    try {
      CommandLine toDevicePath = CommandLine.parse("/usr/sbin/system_profiler SPUSBDataType");
      executor.execute(toDevicePath);
      return new String(baos.toByteArray());
    } catch (Throwable e) {
      return super.preListAllCandidateDevices();
    }

I confess to have never even glanced at a piece of Java software before - nor do I hope to start now.. but I'd imagine that there are plenty of (more) native bridges - between the Cocoa/ObjC subsystem and Java (or at least some way to access the hardware that isn't as brutal and archaic as parsing the output of a utility designed for only the most occasional of system inquiries).

Please let me know if this kind of integration is outside of your team's comfort zone, and I'm sure myself or some other issue onlooker can help. I definitely think this constant polling is affecting Arduino.app's performance, as well as needlessly burdening the host system as a result. I would guess offhand that IOKit and/or SystemConfiguration frameworks would be a good place to start to find an alternative method to obtain the information you need re: the serial ports / whatnot. If not, there are great alternatives such as ORSerialPort that may also be of some service in this endeavor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Help wantedArduino would especially appreciate assistance from the community on this itemOS: OSXSpecific to the Mac OS X (macOS) version of the Arduino IDEfeature requestA request to make an enhancement (not a bug fix)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions