microsoft / v8-jsi

React Native V8 JSI adapter
Other
157 stars 36 forks source link

[0.69] Fix task runner for Node-API (#153) #170

Closed vmoroz closed 1 year ago

vmoroz commented 1 year ago

Cherry pick PR #153 to the main branch.

Original PR description:

Currently the Node-API foreground task runner lifetime is depending on the napi_env lifetime. This is wrong because some tasks must be run after the napi_env is destroyed. This issue causes a crash in React Native for Windows when we do direct debugging.

In this PR we are fixing this issue by implementing a new task runner:

An additional change in this PR: removed NAPI_EXTERN from all implementations as it may cause issues if the function signature is not the same in the .h and .cpp files. This issue was observed while working on the new v8_create_task_runner function.

Note that the new code has prefix v8_ instead of previously used napi_ext_. The reason is that these functions are V8 JS Engine specific and will be never accepted as a part of the Node-API in Node.JS. Thus, the proposal is to use the v8_ prefix instead. Ideally, we should replace js_native_ext_api.h with a new v8_api.h where all declarations will have the v8_ prefix.

Microsoft Reviewers: Open in CodeFlow
vmoroz commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).