Skip to content

Commit faa7387

Browse files
committed
[*kit] fulfil promise immediately
I think this would only commonly happen for cases which files aren't being loaded (debug asmjs), but could happen if multiple ready() calls are made (which is discouraged). Bug: skia: Change-Id: If848aad8603f997661502563136ac590cc9a6d5a Reviewed-on: https://skia-review.googlesource.com/c/181409 Reviewed-by: Kevin Lubick <[email protected]>
1 parent 3ac3a40 commit faa7387

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

experimental/canvaskit/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Fixed
10+
- Potential bug in `ready()` if already loaded.
911

1012
## [0.3.1] - 2019-01-04
1113
### Added

experimental/canvaskit/ready.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ Module['ready'] = function() {
55
return new Promise(function (resolve, reject) {
66
delete Module['then'];
77
Module['onAbort'] = reject;
8-
addOnPostRun(function () {
9-
resolve(Module)
10-
});
8+
if (runtimeInitialized) {
9+
resolve(Module);
10+
} else {
11+
addOnPostRun(function() {
12+
resolve(Module);
13+
});
14+
}
1115
});
1216
}
1317
// TODO(kjlubick): Shut .then() entirely off in 0.4.0 by uncommenting below.

modules/pathkit/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Fixed
10+
- Potential bug in `ready()` if already loaded.
11+
912
## [0.5.1] 2019-01-04
1013

1114
### Changed

modules/pathkit/ready.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ Module['ready'] = function() {
55
return new Promise(function (resolve, reject) {
66
delete Module['then'];
77
Module['onAbort'] = reject;
8-
addOnPostRun(function () {
9-
resolve(Module)
10-
});
8+
if (runtimeInitialized) {
9+
resolve(Module);
10+
} else {
11+
addOnPostRun(function() {
12+
resolve(Module);
13+
});
14+
}
1115
});
1216
}
1317
// TODO(kjlubick): Shut .then() entirely off in 0.6.0 by uncommenting below.

modules/pathkit/tests/util.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ describe('PathKit\'s CubicMap Behavior', function() {
6464
}));
6565
});
6666

67-
});
67+
});

0 commit comments

Comments
 (0)