Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions r/R/arrow-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ s3_finalizer <- new.env(parent = emptyenv())
# needs the C++ library loaded
create_binding_cache()

if (identical(R.version$os, "emscripten")) {
# Disable multithreading on Wasm/Emscripten
options(arrow.use_threads = FALSE)
}

if (tolower(Sys.info()[["sysname"]]) == "windows") {
# Disable multithreading on Windows
# See https://issues.apache.org/jira/browse/ARROW-8379
Expand Down
11 changes: 10 additions & 1 deletion r/src/safe-call-into-r-impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,16 @@ bool SetEnableSignalStopSource(bool enabled) {
}

// [[arrow::export]]
bool CanRunWithCapturedR() { return MainRThread::GetInstance().Executor() == nullptr; }
bool CanRunWithCapturedR() {
#ifdef __EMSCRIPTEN__
// Threading is not supported under Emscripten/WASM. Always take the
// synchronous path to avoid attempting pthread_create which will fail
// with "thread constructor failed: Not supported".
return false;
#else
return MainRThread::GetInstance().Executor() == nullptr;
#endif
Comment on lines +48 to +56
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to add a test (or maybe it's that we actually need to run the tests under wasm(???) to catch this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like maybe we can at least run some R code in the container if not run the test suite. I'll report back.

}

// [[arrow::export]]
std::string TestSafeCallIntoR(cpp11::function r_fun_that_returns_a_string,
Expand Down
Loading