-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to write to WebAssembly.Memory in PHP that is exported to and read in JavaScript in parallel? #121
Comments
Why closing the issue? It starts getting fun! |
Some individuals and institutions do not prefer certain questions. Am not sure if writing to a single Memory instance in PHP or any other language actually solves the entire issue. At the machine am currently testing, creating a Achieved capturing data at localhost to a The question still stands, is it possible to write directly from |
That is the scientific state of mind that have been anticipating by asking these questions while carrying on nonetheless without waiting for answers. Current working code, where
|
Ideally, we can create a Transferable Stream directly from PHP (Go, C++, R, bash, etc.) to JavaScript where
is STDOUT directly from native application or shell script https://bugs.chromium.org/p/chromium/issues/detail?id=1115640, however that concept requires some work to implement correctly without trying to squeeze use cases into API's that were no intended for that purpose. |
To start from the base, what you're trying to do is:
Is that correct? You've to be careful regarding the security of all of this, but it's funny. So you don't need this Is that correct? |
No.
The link to the Chromium bug requesting NativeTransferableStream (see https://bugs.chromium.org/p/chromium/issues/detail?id=89483; https://docs.google.com/document/d/1_KuZzg5c3pncLJPFa8SuVm23AP4tft6mzPCL5at3I9M/edit for description of Transferable Streams) takes the above described process a step further describing a For example, consider
"Security" is not an issue. Whatever code is being executed in the shell can only be performed with user permissions, similar to how Native Messaging and Native File System operate right now. |
The above is description of the full context of what am trying to achieve. For this issue am trying to determine if it is even possible to create a WASM Memory instance in a given programming language outside of a JavaScript browsing context, export that single WASM Memory instance to JavaScript context, write to that shared memory in the native application or shell script, for example, raw audio bytes, grow the WASM Memory when necessary dynamically due to content length of binary data sent to STDOUT which is actually the WASM Memory, not a terminal, read that WASM Memory in JavaScript while the write is occurring. There are two possible paths
|
Am already able to achieve
within the limitations of WASM Memory and JavaScript implementations, at the code at #121 (comment) by substituting, for example (
for
though it is difficult to synchronize the write and read when
before starting audio output at JavaScript to keep the write ahead of the read. Asked similar question at WASI repository WebAssembly/WASI#307 where it appears interaction of WASI with JavaScript (in the browser; web platform) is off-topic. |
Re "Security" all of the native applications or shell scripts that will be used in the procedure can be declared beforehand. All of the code that is to be used can be stored in a single directory which user grants read/write permissions for, similar to using Native File System, see https://github.com/guest271314/captureSystemAudio/blob/master/native_messaging/file_stream/app/captureSystemAudio.js for a version of the code that uses Native Messaging and Native File System to stream to one or more files and read the files instead of STDOUT directly
|
Put together a minimal, verifiable, complete working example of streaming from Posting the code here as not infrequently crash the browser and, or the OS in the midst of ongoing experiments. Flow chart
Chromium Native Messaging extenstion. app/ manifest.json
background.js
set_externally_connectable.js
host/ native_messaging_stream.json (
index.php
captureSystemAudio.sh
at the arbitrary web page, in this case, MDN, where we previously set the matching URL pattern at At web page
A version using Testing at a legacy 4.15.0-20-lowlatency 32-bit kernel attempted to grow memory to 30 minutes of data, with maximum set to 1 hour of data
resulting in 16 minutes and 43 seconds of data being written to memory, observable at recorded audio Asked the question if 1GB is the maximum the underlying memory can grow at 32-bit architectures at https://bugs.chromium.org/p/v8/issues/detail?id=7881.
Ideally, in this case, we should be able to stream directly to One approach to reduce memory usage would be to write Opus audio to memory and decode to raw PCM as |
One issue with I solved the use case using existing web platform technologies https://github.com/guest271314/NativeTransferableStreams. Thanks! |
:-) |
Summary
Consider
where due to Chromium refusing to capture monitor devices when
getUserMedia({audio: true})
is executed at Linux we usephp -S localhost:8000
to stream output ofpassthru()
toResponse.body
(ReadableStream
) fromfetch()
call.Ideally we should be able to write the output from the shell script directly to a WebAssembly Memory instance, grow the shared array buffer if necessary, export that same Memory instance to JavaScript for the purpose of reading the shared memory in parallel to writing to and possible growing the single buffer, in this case, to stream audio in "real-time" using
AudioWorklet
, and finally flush the buffer once the stream closes.Is this possible using the code in this repository?
Additional details
See https://github.com/WebAudio/web-audio-api-v2/issues/5#issuecomment-673831406
The text was updated successfully, but these errors were encountered: