Closed ClosetGeek-Git closed 1 year ago
'failure' was a typo above, I meant to say I'm not familiar with PHP FFI, I'm a C/C++ extension developer so I generally don't use FFI.
Hey @ClosetMonkey
FFI installation , composer.json is checking whether ffi it's enable or not. that's why it's required. if you compile without ffi or it's disabled on windows, your php doesn't have ffi.
I have ffi enabled and composers verification is failing. I'll need to check a few things because I'm dealing with an embeded PHP SAPI so it can be an issue with my current distribution.
composer installs php-webview on the same machine using the standard PHP cli without a problem, which points to it being an issue with my SAPI.
I'm starting to have doubts however considering the issues rust and go users are having with threads and concurrency without using dispatch, and this can be where vanilla PHP becomes an issue in php-webview.
To demonstrate add 'sleep(10);' before return within your bound callback. Otherwise it's looking beautiful in it's current state.
Yes, it's an issue. php is not language like go and rust. the issue can be solved by using library like pthread, swoole, or reactphp. If you wanna contribute, you can develop some cool feature, and create pull request.
It's not a "php is not a language like" issue, it's the fact that webview_run() has a while loop blocking the main thread. Change GetMessage with PeekMessage (at least on windows) and turn the while loop into an if statement with run() returning an int, then loop webview_run in PHP itself. The Macos native webview is ran in a background thread so it's run() implementation doesn't effect the main thread. Haven't dug into the Linux implementation tho, i'll get to that in a week or two.
I'm working on a native extension that I won't be able to share, but look into php_select on windows. This allows stream_select to multiplex between socket/stream based events as well as non socket/stream HANDLEs using WaitForMultipleObjects on Windows. If you can find a way to get php_select to wait on a HANDLE from webview via FFI you'll be able to handle webview events in ReactPHP.
updated my last comment
ext-ffi is required by composer. I'm not failure with php's ffi capabilities, but didn't ext-ffi become obsolete when ffi was approved and incorporated into PHP 8.2?