0hr / php-webview

PHP bindings for Webview
56 stars 5 forks source link

ext-ffi? #2

Closed ClosetGeek-Git closed 1 year ago

ClosetGeek-Git commented 1 year ago

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?

ClosetGeek-Git commented 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.

0hr commented 1 year ago

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.

ClosetGeek-Git commented 1 year ago

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.

ClosetGeek-Git commented 1 year ago

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.

ClosetGeek-Git commented 1 year ago

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.

0hr commented 1 year ago

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.

ClosetGeek-Git commented 1 year ago

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.

ClosetGeek-Git commented 1 year ago

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.

ClosetGeek-Git commented 1 year ago

updated my last comment