ntk 8.17.7 → 8.17.8
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/lib/fontconfig.js +14 -6
- package/package.json +1 -1
package/lib/fontconfig.js
CHANGED
|
@@ -397,7 +397,7 @@ function censusBytes() {
|
|
|
397
397
|
const deadline = performance.now() + PREWARM_WAIT_MS;
|
|
398
398
|
let status = prewarmStatus(census.base);
|
|
399
399
|
while (status === null && !census.exited && performance.now() < deadline) {
|
|
400
|
-
|
|
400
|
+
nap();
|
|
401
401
|
status = prewarmStatus(census.base);
|
|
402
402
|
}
|
|
403
403
|
census.bytes = null;
|
|
@@ -818,8 +818,16 @@ function spawnToFiles(fcs, bests = []) {
|
|
|
818
818
|
return entries;
|
|
819
819
|
}
|
|
820
820
|
|
|
821
|
-
// the synchronous path's nap while a prewarm finishes
|
|
822
|
-
|
|
821
|
+
// the synchronous path's nap while a prewarm finishes: a millisecond's
|
|
822
|
+
// Atomics.wait on a cell made by the first nap. Not at load: a page that is
|
|
823
|
+
// not cross-origin isolated has no SharedArrayBuffer, so one made here was a
|
|
824
|
+
// ReferenceError in every browser bundle of ntk, which never naps — there is
|
|
825
|
+
// no prewarm without node (NOT_NODE)
|
|
826
|
+
let napCell;
|
|
827
|
+
function nap() {
|
|
828
|
+
napCell ??= new Int32Array(new SharedArrayBuffer(4));
|
|
829
|
+
Atomics.wait(napCell, 0, 0, 1);
|
|
830
|
+
}
|
|
823
831
|
|
|
824
832
|
// How long the synchronous path waits on a prewarm before asking fc-match
|
|
825
833
|
// itself. fc-match answers in tens of milliseconds, and a prewarm that is
|
|
@@ -836,7 +844,7 @@ function answerSync(fc, entry) {
|
|
|
836
844
|
let left = readPrewarm(entry.base);
|
|
837
845
|
// a child that is gone has left all it ever will
|
|
838
846
|
while (left === null && !entry.exited && performance.now() < deadline) {
|
|
839
|
-
|
|
847
|
+
nap();
|
|
840
848
|
left = readPrewarm(entry.base);
|
|
841
849
|
}
|
|
842
850
|
if (inflight.get(fc) === entry) inflight.delete(fc);
|
|
@@ -866,7 +874,7 @@ function firstOfPrewarm(spec, entry) {
|
|
|
866
874
|
const deadline = performance.now() + PREWARM_WAIT_MS;
|
|
867
875
|
let status = prewarmStatus(entry.base);
|
|
868
876
|
while (status === null && !entry.exited && performance.now() < deadline) {
|
|
869
|
-
|
|
877
|
+
nap();
|
|
870
878
|
status = prewarmStatus(entry.base);
|
|
871
879
|
}
|
|
872
880
|
// not answered, or not yet: the whole read is what decides, and reports
|
|
@@ -893,7 +901,7 @@ function bestOfPrewarm(spec, entry) {
|
|
|
893
901
|
const deadline = performance.now() + PREWARM_WAIT_MS;
|
|
894
902
|
let left = readPrewarm(entry.base);
|
|
895
903
|
while (left === null && !entry.exited && performance.now() < deadline) {
|
|
896
|
-
|
|
904
|
+
nap();
|
|
897
905
|
left = readPrewarm(entry.base);
|
|
898
906
|
}
|
|
899
907
|
if (left === null) return null;
|