You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes the Linux/Windows/Android bridge_example handshake-timeout failure
by making Python and Dart share the SAME `global_enqueue_handler_func`
cell on every platform.
Before: the wheel-installed dart_bridge.so (cibuildwheel) and the
Flutter-built libflet_bridge.so each compiled a full copy of
dart_bridge.c — two separate binary instances, two separate copies of
the static `global_enqueue_handler_func`. Python's
set_enqueue_handler_func wrote to the wheel's copy; Dart's
DartBridge_EnqueueMessage read libflet_bridge's copy (NULL); messages
were silently dropped.
After: the core lives in libflet_bridge ONLY. The wheel ships a thin
shim that resolves the core's exports at PyInit time via runtime
symbol lookup (dlsym(RTLD_DEFAULT) → dlopen RTLD_GLOBAL fallback on
Linux/macOS, LoadLibrary+GetProcAddress on Windows). One global cell,
visible to both sides.
Changes:
- native/dart_bridge.c: drop the Python-callable methods. Exports
three symbols for the shim to resolve:
* dart_bridge_global_enqueue_handler_func (PyObject*, was static)
* dart_bridge_post_to_dart (helper that wraps Dart_PostCObject_DL
so the shim doesn't need its own copy of dart_api_dl.c)
* existing DartBridge_InitDartApiDL + DartBridge_EnqueueMessage
- native/dart_bridge_shim.c (NEW): PyInit_dart_bridge resolves the
three exports above via shim_sym_lookup(); set_enqueue_handler_func
writes through the resolved pointer; send_bytes calls through the
resolved function pointer. ImportError if libflet_bridge isn't
loaded into the process (catches misconfiguration loudly).
- python/setup.py: compile only dart_bridge_shim.c; add -ldl on Linux
for the dlopen/dlsym used by the shim. Dropped dart_api_dl.c from
the wheel's sources (the shim doesn't call Dart_PostCObject_DL
directly).
- darwin/Classes/dart_bridge_shim.c (symlink): so the Apple static
link picks both .c files into the framework. Apple's
dlsym(RTLD_DEFAULT) finds the symbols in-process (smoke-tested:
macOS bridge_example_macos still passes).
- ci.yml + test-bridge-build.yml: drop continue-on-error from
bridge_example_linux and bridge_example_windows — they should pass
now.
Verified locally on macOS: `flutter test integration_test -d macos`
still green. CI verification pending — pushing to dart-bridge will
exercise all three desktop platforms.
0 commit comments