Commit Graph
2 Commits
Author SHA1 Message Date
Aleksandrs Sevastjanovs bb7a15f436 Stop flserial's SerialThread spinning on an idle serial port
POSIX opens the port O_NONBLOCK with VMIN/VTIME=0, and fl_open skips
setTimeout on Linux/macOS, so the default all-zero Timeout makes
SerialThread's read() return immediately. With no traffic the reader
spins at 100% of a core for the whole session. Release builds and a
minimized window do not help because it is a native thread.

Set a 10 ms read/select timeout on POSIX. Data still wakes select
immediately; the timeout only bounds idle wakeups and queued-write
latency. Apply the same change to the macOS copy of flserial.

Follow-up to #557.

Measured with a PTY harness, idle: 99.9% of one core before, 0.2%
after. RX and TX still pass.
2026-10-30 16:15:15 +00:00
just-stuff-tm 2474389099 Fix Linux USB open crash and the glibc 2.39 release bundle.
BETA-99.0.0 segfaults when a USB companion transmits as soon as the port
opens, and the Linux release fails to load on Ubuntu 24.04 and Linux
Mint 22 (glibc 2.39). Fixes #600.

fl_open starts SerialThread before Dart installs fl_set_callback. A Seeed
Wio Tracker L1 sends bytes immediately, and the reader called that null
pointer (segfault at ip 0, FlSerial+0x44b8). Vendor MeshEnvy/flserial
e1864de under third_party/flserial. That is the 0.3.5 FFI API this app
already calls (openPort, setCallback, setByteSize8, setDTR), not official
grzesl/flserial 0.7.3. The reader waits until the callback is set, and
the port mutexes are initialized before the thread starts. Merging this
makes zjs81/meshcore-open the owner of that vendored copy.

The release libflserial.so needed GLIBC_2.42 for cfsetispeed and
cfsetospeed, so USB discovery failed on glibc 2.39 before the port
opened. Bind those symbols at GLIBC_2.2.5 and pass the legacy baud values
those symbols expect. 115200 is octal 0010002. glibc 2.42 turned the B*
macros into plain numbers, so passing 115200 to the old symbol would
select the wrong rate.

flutter_onnxruntime 1.9.0 needs libonnxruntime.so.1 from ONNX Runtime
1.28.3. The zip did not ship that file, and the plugin RUNPATH was the
build machine's download directory. The loader uses the plugin path for
this library. The install copies libonnxruntime.so, .so.1, .so.1.28.3,
and libonnxruntime_providers_shared.so into bundle/lib. The plugin build
RPATH is $ORIGIN followed by the download directory: $ORIGIN is bundle/lib
at runtime, and the download directory is what ld needs while linking.
Dropping it makes the release link fail. The executable keeps DT_RPATH
$ORIGIN/lib for its own plugins.

Checked on Ubuntu 26.04.1 (glibc 2.43) with Flutter 3.47.7. Opening
/dev/ttyACM0 at 115200 set both termios2 speeds to 115200 and delivered
data after fl_set_callback (last length 402). The built libflserial.so
has no GLIBC_2.42 requirement. flutter build linux --release succeeded.
With the plugin's absolute build path removed and LD_LIBRARY_PATH unset,
ldd resolved libonnxruntime.so.1 from bundle/lib.
2026-10-16 20:11:05 -04:00