react-native-worklets 0.4.1 → 0.4.2
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/RNWorklets.podspec
CHANGED
|
@@ -10,7 +10,7 @@ worklets_assert_new_architecture_enabled($new_arch_enabled)
|
|
|
10
10
|
|
|
11
11
|
ios_min_version = '13.4'
|
|
12
12
|
|
|
13
|
-
feature_flags = "-DWORKLETS_FEATURE_FLAGS=\"#{
|
|
13
|
+
feature_flags = "-DWORKLETS_FEATURE_FLAGS=\"#{worklets_get_static_feature_flags()}\""
|
|
14
14
|
version_flags = "-DWORKLETS_VERSION=#{package['version']}"
|
|
15
15
|
|
|
16
16
|
Pod::Spec.new do |s|
|
|
@@ -42,6 +42,12 @@ Pod::Spec.new do |s|
|
|
|
42
42
|
# See https://github.com/facebook/react-native/blob/c925872e72d2422be46670777bfa2111e13c9e4c/packages/react-native/scripts/cocoapods/new_architecture.rb#L71.
|
|
43
43
|
install_modules_dependencies(s)
|
|
44
44
|
|
|
45
|
+
s.dependency 'React-jsi'
|
|
46
|
+
using_hermes = ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == '1'
|
|
47
|
+
if using_hermes && !$worklets_config[:is_tvos_target]
|
|
48
|
+
s.dependency 'React-hermes'
|
|
49
|
+
end
|
|
50
|
+
|
|
45
51
|
# React Native doesn't expose these flags, but not having them
|
|
46
52
|
# can lead to runtime errors due to ABI mismatches.
|
|
47
53
|
# There's also
|
|
@@ -16,13 +16,6 @@ const auto LOW = CAFrameRateRangeMake(24, 30, 30);
|
|
|
16
16
|
const auto POOR = CAFrameRateRangeMake(10, 24, 24);
|
|
17
17
|
} // namespace FrameRateRange
|
|
18
18
|
|
|
19
|
-
enum FrameRateRangeEnum {
|
|
20
|
-
BEST,
|
|
21
|
-
STANDARD,
|
|
22
|
-
LOW,
|
|
23
|
-
POOR,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
19
|
@implementation AnimationFrameQueue {
|
|
27
20
|
/* DisplayLink is thread safe. */
|
|
28
21
|
WorkletsDisplayLink *displayLink_;
|
|
@@ -30,7 +23,7 @@ enum FrameRateRangeEnum {
|
|
|
30
23
|
std::mutex callbacksMutex_;
|
|
31
24
|
std::chrono::duration<double, std::milli> timeDeltas_[TIME_SAMPLES_AMOUNT];
|
|
32
25
|
int timeDeltaIndex_;
|
|
33
|
-
|
|
26
|
+
CAFrameRateRange currentFrameRate_;
|
|
34
27
|
}
|
|
35
28
|
|
|
36
29
|
typedef void (^AnimationFrameCallback)(WorkletsDisplayLink *displayLink);
|
|
@@ -43,7 +36,7 @@ typedef void (^AnimationFrameCallback)(WorkletsDisplayLink *displayLink);
|
|
|
43
36
|
if constexpr (worklets::StaticFeatureFlags::getFlag("IOS_DYNAMIC_FRAMERATE_ENABLED")) {
|
|
44
37
|
bool supportsProMotion = [UIScreen mainScreen].maximumFramesPerSecond > 60;
|
|
45
38
|
SEL frameCallback = supportsProMotion ? @selector(executeQueueForProMotion:) : @selector(executeQueue:);
|
|
46
|
-
|
|
39
|
+
currentFrameRate_ = supportsProMotion ? FrameRateRange::BEST : FrameRateRange::STANDARD;
|
|
47
40
|
displayLink_ = [WorkletsDisplayLink displayLinkWithTarget:self selector:frameCallback];
|
|
48
41
|
} else {
|
|
49
42
|
displayLink_ = [WorkletsDisplayLink displayLinkWithTarget:self selector:@selector(executeQueue:)];
|
|
@@ -111,19 +104,24 @@ typedef void (^AnimationFrameCallback)(WorkletsDisplayLink *displayLink);
|
|
|
111
104
|
// Perform this on every TIME_SAMPLES_AMOUNT-nth frame instead of each one
|
|
112
105
|
return;
|
|
113
106
|
}
|
|
114
|
-
float
|
|
107
|
+
float averageComputationTime = 0;
|
|
115
108
|
for (int i = 0; i < TIME_SAMPLES_AMOUNT; i++) {
|
|
116
|
-
|
|
109
|
+
averageComputationTime += timeDeltas_[i].count();
|
|
110
|
+
}
|
|
111
|
+
averageComputationTime = averageComputationTime / TIME_SAMPLES_AMOUNT;
|
|
112
|
+
CAFrameRateRange frameRateRange;
|
|
113
|
+
if (averageComputationTime < 8) {
|
|
114
|
+
frameRateRange = FrameRateRange::BEST;
|
|
115
|
+
} else if (averageComputationTime < 16) {
|
|
116
|
+
frameRateRange = FrameRateRange::STANDARD;
|
|
117
|
+
} else if (averageComputationTime < 33) {
|
|
118
|
+
frameRateRange = FrameRateRange::LOW;
|
|
119
|
+
} else {
|
|
120
|
+
frameRateRange = FrameRateRange::POOR;
|
|
117
121
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
} else if (averageFrameDuration < 16 && curentFrameRate_ != STANDARD) {
|
|
122
|
-
displayLink_.preferredFrameRateRange = FrameRateRange::STANDARD;
|
|
123
|
-
} else if (averageFrameDuration < 33 && curentFrameRate_ != LOW) {
|
|
124
|
-
displayLink_.preferredFrameRateRange = FrameRateRange::LOW;
|
|
125
|
-
} else if (curentFrameRate_ != POOR) {
|
|
126
|
-
displayLink_.preferredFrameRateRange = FrameRateRange::POOR;
|
|
122
|
+
if (currentFrameRate_.preferred != frameRateRange.preferred) {
|
|
123
|
+
displayLink_.preferredFrameRateRange = frameRateRange;
|
|
124
|
+
currentFrameRate_ = frameRateRange;
|
|
127
125
|
}
|
|
128
126
|
}
|
|
129
127
|
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* version used to build the native part of the library in runtime. Remember to
|
|
4
4
|
* keep this in sync with the version declared in `package.json`
|
|
5
5
|
*/
|
|
6
|
-
export declare const jsVersion = "0.4.
|
|
6
|
+
export declare const jsVersion = "0.4.2";
|
|
7
7
|
//# sourceMappingURL=jsVersion.d.ts.map
|
package/package.json
CHANGED
|
@@ -66,7 +66,7 @@ def worklets_assert_new_architecture_enabled(new_arch_enabled)
|
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
def
|
|
69
|
+
def worklets_get_static_feature_flags()
|
|
70
70
|
feature_flags = {}
|
|
71
71
|
|
|
72
72
|
static_feature_flags_path = File.path('./src/featureFlags/staticFlags.json')
|
package/src/utils/jsVersion.ts
CHANGED