node-gtk 4.0.0 → 4.0.1
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/loop.js
CHANGED
|
@@ -45,10 +45,22 @@ function start() {
|
|
|
45
45
|
* macrotask lets the module's top-level microtask return first, so the queue
|
|
46
46
|
* drains and the loop integration takes over from a clean (non-nested) state.
|
|
47
47
|
*
|
|
48
|
+
* We defer with setTimeout, NOT setImmediate. A setImmediate callback runs
|
|
49
|
+
* *inside* Node's immediate-processing machinery (native CheckImmediate ->
|
|
50
|
+
* processImmediate). Because `run` never returns (it blocks in the GLib main
|
|
51
|
+
* loop until the app quits), CheckImmediate never reaches the code that stops
|
|
52
|
+
* Node's private immediate uv_idle handle, so that handle stays active forever.
|
|
53
|
+
* An active idle handle pins uv_backend_timeout() at 0, which makes the nested
|
|
54
|
+
* uv-in-GLib loop busy-spin at 100% CPU (worse on Node 26 / libuv 1.52, where
|
|
55
|
+
* the immediate's wakeup eventfd also stays signalled). A one-shot timer is
|
|
56
|
+
* removed from libuv's timer heap before its callback runs, so blocking inside
|
|
57
|
+
* it leaves no libuv state active and the loop can sleep normally. See #477.
|
|
58
|
+
*
|
|
48
59
|
* Under CommonJS (and inside signal callbacks) we are not in a microtask, so we
|
|
49
60
|
* run synchronously and preserve the original blocking semantics exactly.
|
|
50
61
|
*
|
|
51
62
|
* https://github.com/romgrk/node-gtk/issues/442
|
|
63
|
+
* https://github.com/romgrk/node-gtk/issues/477
|
|
52
64
|
*
|
|
53
65
|
* Returns the native call's result when run synchronously (so e.g.
|
|
54
66
|
* `const status = app.run()` keeps working under CommonJS); returns undefined
|
|
@@ -64,7 +76,7 @@ function runLoopEntry(run) {
|
|
|
64
76
|
start()
|
|
65
77
|
|
|
66
78
|
if (internal.IsRunningMicrotasks()) {
|
|
67
|
-
|
|
79
|
+
setTimeout(run, 0)
|
|
68
80
|
return undefined
|
|
69
81
|
}
|
|
70
82
|
return run()
|
package/package.json
CHANGED
|
Binary file
|