arduino / arduino-ide

Arduino IDE 2.x
https://www.arduino.cc/en/software
GNU Affero General Public License v3.0
2.33k stars 394 forks source link

Canceling compilation or upload doesn't kill tool process #2517

Closed per1234 closed 4 weeks ago

per1234 commented 1 month ago

Describe the problem

When a compile, upload, or burn bootloader operation is triggered by the Arduino IDE user, command line tool(s) (e.g., avr-gcc, AVRDUDE) are invoked. It is these tools that actually perform the compilation, upload, or burn the bootloader.

A "CANCEL" button was added to the compile, upload, and burn bootloader progress notifications (https://github.com/arduino/arduino-ide/pull/2334 / https://github.com/arduino/arduino-ide/commit/2a325a5b74a7ea80645cd2da74588f706292f4ff). Clicking this button cancels the operation in the Arduino IDE GUI, but doesn't kill the tool process. The tool process continues to run just as it would have done if the button had not been pressed

πŸ› The button is misleading, since the user is sure to have the reasonable expectation that the tool process will be canceled. πŸ› This can cause very confusing problems when the user triggers a new operation and it has a collision with the process that was still running from the canceled operation. Normally the existence and status of an ongoing process would be communicated to the user via the Arduino IDE UI, but after using the "cancel" feature, there is no such communication. So it will be difficult for the user (and those who support their report) to understand why this is happening.

To reproduce

Equipment

Demo

  1. Select File > New Sketch from the Arduino IDE menus.
  2. Select the port from Arduino IDE's Tools > Port menu.
  3. Select Tools > Board > Arduino AVR Boards > Arduino Duemilanove or Diecimila from the Arduino IDE menus. β“˜ This board was chosen arbitrarily as one that is installed by default and likely to produce a relatively long duration upload process (in order to ensure it will still be running when the second upload is triggered). But the fault is not limited to this board.
  4. Select Sketch > Upload from the Arduino IDE menus.
  5. Wait for the "Uploading..." notification to appear.
  6. Click the "CANCEL" button in the notification.
  7. Select Sketch > Upload from the Arduino IDE menus.

πŸ› The upload fails with an unexpected "Access is denied." error. The reason is that the avrdude process from the first upload operation that was triggered at step (4) was still running, even though that operation was canceled.

Expected behavior

The process is killed when the "CANCEL" button is clicked.

- OR -

If it is not possible to kill the process, then remove the misleading "CANCEL" button.

Arduino IDE version

2.3.3

Operating system

Operating system version

Additional context

I used the collision of port usage in the demo as a simple and dramatic way to show that the avrdude process from the "canceled" upload was still running. However, you can also use a tool such as ps -e on POSIX systems or Windows Task Manager to verify that the process continues running even after the operation is canceled.


Related: https://github.com/arduino/arduino-ide/issues/1199

Issue checklist

cmaglie commented 4 weeks ago

Fixed in https://github.com/arduino/arduino-cli/pull/2726

kittaakos commented 1 week ago

Fixed in arduino/arduino-cli#2726

Note that the fix is not yet in the nightly builds.

https://github.com/arduino/arduino-ide/blob/63e9dfd7f5949c77ffbfb6175e2e9c2991317bca/arduino-ide-extension/package.json#L172-L174