Skip to content

Commit 7ebc770

Browse files
committed
test(runtime): gesture recognizer leak cycle exists only when every wrapper is in scope
Under scope extended a plain UITapGestureRecognizer is not a canary (canary) or a rooted wrapper (rooted), so its JS state, the edge back to the view, dies with its wrapper. The view is then deallocated and there is no cycle for the probe to report.
1 parent 0517586 commit 7ebc770

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎TestRunner/app/tests/WrapperLifetimeLeaksTests.js‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ describe("Wrapper lifetime leak cycles", function () {
55
var mode = runtime.getConfig("wrapperLifetimeMode");
66
var rooted = mode === "rooted";
77
var canary = mode === "canary";
8+
// A plain recognizer's JS state outlives its wrapper only when every
9+
// wrapper is in scope; otherwise the edge back to its view dies with it.
10+
var gestureCycle = (rooted || canary) && runtime.getConfig("wrapperLifetimeScope") === "all";
811

912
// One class per shape, so a report names the shape.
1013
function shape(name) {
@@ -374,7 +377,7 @@ describe("Wrapper lifetime leak cycles", function () {
374377
expect(held[0].reached).toBe(true);
375378
expect(held[0].reachedFrom).toContain("TNSLeakHeldView");
376379
expect(held[0].out).toContain("_layer");
377-
if (rooted || canary) {
380+
if (gestureCycle) {
378381
var gesture = inspected("TNSLeakGestureView");
379382
expect(gesture.length).toBe(1);
380383
expect(gesture[0].out).toContain("_gestureRecognizers");
@@ -389,12 +392,12 @@ describe("Wrapper lifetime leak cycles", function () {
389392
it("reports a cycle through a view's gesture recognizer only when strict, marked uncertain", function () {
390393
expect(cyclesNaming(reports.default, "TNSLeakGestureView").length).toBe(0);
391394
var found = cyclesNaming(reports.strict, "TNSLeakGestureView");
392-
expect(found.length > 0).toBe(rooted || canary);
395+
expect(found.length > 0).toBe(gestureCycle);
393396
found.forEach(function (cycle) {
394397
expect(cycle.uncertain).toBe(true);
395398
expect(cycle.reasons.join("\n")).toMatch(/UITapGestureRecognizer 0x[0-9a-f]+: retainCount/);
396399
});
397-
expect(aliveNamed(watched, "TNSLeakGestureView")).toBe(rooted || canary ? 1 : 0);
400+
expect(aliveNamed(watched, "TNSLeakGestureView")).toBe(gestureCycle ? 1 : 0);
398401
});
399402

400403
it("keeps the native side of every reported cycle alive", function () {

0 commit comments

Comments
 (0)