react-native-nitro-input 0.3.6 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.7
4
+
5
+ - **Android: no longer breaks VisionCamera frame processors.** NitroInput
6
+ linked `libworklets.so` although it uses only worklets' header-inline API,
7
+ and as a Nitro package it loads at app start, so it became the first library
8
+ to load `libworklets.so`. On Android that changes which copy of worklets'
9
+ weak RTTI each library binds to; `react-native-vision-camera-worklets`'
10
+ frame-processor queue then failed worklets' `dynamic_cast`, the runtime got a
11
+ null queue, and opening any frame-processor camera crashed with SIGSEGV in
12
+ `worklets::WorkletRuntime::scheduleImpl`. Worklets is now used headers-only
13
+ (no `DT_NEEDED`), and `installRuntime` checks the UI runtime holder by type
14
+ name instead of `dynamic_cast`, which is not reliable across shared libraries
15
+ on Android.
16
+
3
17
  ## 0.3.6
4
18
 
5
19
  - **A controlled `selection` rendered before the latest keystrokes is
@@ -39,10 +39,23 @@ include_directories(
39
39
 
40
40
  # Worklets are optional: with react-native-worklets installed the views can
41
41
  # run `transform` / `onChangeText` worklets synchronously on the UI thread.
42
+ #
43
+ # Headers only, deliberately NOT linked: the bridge uses worklets' header-inline
44
+ # API and imports no symbol from libworklets.so (NDK links with --no-undefined,
45
+ # so if that ever changes the build fails here instead of misbehaving).
46
+ # Linking would add a DT_NEEDED on libworklets.so, and since NitroInput is a
47
+ # Nitro package (loaded at app start, ahead of most libraries) it would become
48
+ # the first library to load libworklets.so. On Android that changes which copy
49
+ # of worklets' weak RTTI (e.g. worklets::AsyncQueue) each library binds to, and
50
+ # react-native-vision-camera-worklets' frame-processor queue then fails worklets'
51
+ # dynamic_cast: null queue, SIGSEGV in WorkletRuntime::scheduleImpl.
42
52
  find_package(react-native-worklets CONFIG QUIET)
43
53
  if(react-native-worklets_FOUND)
44
54
  target_compile_definitions(${PACKAGE_NAME} PRIVATE NITRO_INPUT_WORKLETS=1)
45
- target_link_libraries(${PACKAGE_NAME} react-native-worklets::worklets)
55
+ target_include_directories(${PACKAGE_NAME} PRIVATE
56
+ $<TARGET_PROPERTY:react-native-worklets::worklets,INTERFACE_INCLUDE_DIRECTORIES>)
57
+ target_compile_definitions(${PACKAGE_NAME} PRIVATE
58
+ $<TARGET_PROPERTY:react-native-worklets::worklets,INTERFACE_COMPILE_DEFINITIONS>)
46
59
  message(STATUS "NitroInput: react-native-worklets found, worklet support enabled")
47
60
  else()
48
61
  message(STATUS "NitroInput: react-native-worklets not found, worklet support disabled")
@@ -12,8 +12,10 @@
12
12
  #include <worklets/Compat/Holders.h>
13
13
  #include <worklets/WorkletRuntime/WorkletRuntime.h>
14
14
 
15
+ #include <cstring>
15
16
  #include <memory>
16
17
  #include <mutex>
18
+ #include <typeinfo>
17
19
 
18
20
  namespace margelo::nitro::nitroinput::nitroinputworklets {
19
21
 
@@ -72,8 +74,18 @@ bool installRuntime(Runtime& rt, const Value& holder) {
72
74
  if (!holder.isObject()) return false;
73
75
  Object object = holder.asObject(rt);
74
76
  if (!object.hasNativeState(rt)) return false;
75
- auto state = std::dynamic_pointer_cast<worklets::WorkletRuntimeHolder>(object.getNativeState(rt));
76
- if (!state || !state->runtime_) return false;
77
+ auto nativeState = object.getNativeState(rt);
78
+ // Not dynamic_cast: on Android each shared library can carry its own copy of
79
+ // an inline class's type_info, and libc++ compares them by address, so the
80
+ // cast fails whenever this library and libworklets.so bind different copies.
81
+ // Compare the mangled names instead (what worklets' own
82
+ // getWorkletRuntimeFromHolder trusts with a static cast).
83
+ if (!nativeState ||
84
+ std::strcmp(typeid(*nativeState).name(), typeid(worklets::WorkletRuntimeHolder).name()) != 0) {
85
+ return false;
86
+ }
87
+ auto state = std::static_pointer_cast<worklets::WorkletRuntimeHolder>(nativeState);
88
+ if (!state->runtime_) return false;
77
89
  std::lock_guard<std::mutex> lock(gMutex);
78
90
  gRuntime = state->runtime_;
79
91
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nitro-input",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "Native text for React Native, built with Nitro: a text and amount input with native formatting, masks and a Torph-style reflow, and an animated number (odometer, SwiftUI-style numeric text, ticker) whose digits roll or swap natively, with currency layouts and animated currency switches, shrink-to-fit, a loading shimmer and a jackpot reveal.",
5
5
  "main": "lib/commonjs/src/index.js",
6
6
  "module": "lib/module/src/index.js",