Skip to content

Commit

Permalink
[retain cycles] Add test that shows a missing part of the trace
Browse files Browse the repository at this point in the history
Summary: We are missing the part about the execution of `hitViewInScrubber` that will explain how the cycle took place.

Reviewed By: geralt-encore

Differential Revision: D57496059

fbshipit-source-id: 3366358ab772635f31a2cf82d2ac5cfb6031eff2
  • Loading branch information
dulmarod authored and facebook-github-bot committed May 17, 2024
1 parent 17e0130 commit 2880cfe
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions infer/tests/codetoanalyze/objc/pulse/issues.exp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ codetoanalyze/objc/pulse/retain_cycles/RetainCycleBlockCapturedVar.m, LinkResolv
codetoanalyze/objc/pulse/retain_cycles/RetainCycleBlocksCopy.m, Process.retain_self_in_block_bad, 1, RETAIN_CYCLE, no_bucket, ERROR, [assignment of self->_handler part of the trace starts here,parameter `self` of Process.retain_self_in_block_bad,when calling `Process.setHandler:` here,parameter `self` of Process.setHandler:,assigned,self captured by block defined in RetainCycleBlocksCopy.m:24 here,retain cycle here]
codetoanalyze/objc/pulse/retain_cycles/RetainCycleDeduplication.m, CViewController.setCaptureInteractionController_bad:, 5, RETAIN_CYCLE, no_bucket, ERROR, [assignment of self->_captureController part of the trace starts here,parameter `self` of CViewController.setCaptureInteractionController_bad:,assigned,assignment of self->_captureController->_delegate part of the trace starts here,parameter `self` of CViewController.setCaptureInteractionController_bad:,parameter `captureController` of CViewController.setCaptureInteractionController_bad:,taking "then" branch,assigned,when calling `CaptureController.setDelegate:` here,parameter `self` of CaptureController.setDelegate:,assigned,retain cycle here]
codetoanalyze/objc/pulse/retain_cycles/RetainCycleExampleWeak.m, RetainCycleExampleWeak.test_strong_adapter_cycle_bad, 1, RETAIN_CYCLE, no_bucket, ERROR, [assignment of self->_feed.strong_adapter._feed part of the trace starts here,parameter `self` of RetainCycleExampleWeak.test_strong_adapter_cycle_bad,in call to `AFeed.strong_adapter`,parameter `self` of AFeed.strong_adapter,returned,return from call to `AFeed.strong_adapter`,when calling `Adapter.setFeed:` here,parameter `self` of Adapter.setFeed:,assigned,retain cycle here]
codetoanalyze/objc/pulse/retain_cycles/RetainCycleIncompleteTrace.m, TestView._newGestureTypeFromGesture:, 3, RETAIN_CYCLE, no_bucket, ERROR, [assignment of self->_lastTouchedView part of the trace starts here,parameter `self` of TestView._newGestureTypeFromGesture:,assigned,retain cycle here]
codetoanalyze/objc/pulse/retain_cycles/RetainCycleIvars.m, test_bad, 3, RETAIN_CYCLE, no_bucket, ERROR, [assignment of d->_user part of the trace starts here,parameter `project` of test_bad,assigned,assigned,assignment of d->_user->_data part of the trace starts here,parameter `project` of test_bad,assigned,assigned,retain cycle here]
codetoanalyze/objc/pulse/retain_cycles/RetainCycleLength3.m, strongcycle_length3_bad, 6, RETAIN_CYCLE, no_bucket, ERROR, [assignment of a_obj->_b part of the trace starts here,allocated by call to `alloc` (modelled),in call to `NSObject.init` (modelled),assigned,when calling `MyClass1.setB:` here,parameter `self` of MyClass1.setB:,assigned,assignment of b_obj->_c part of the trace starts here,allocated by call to `alloc` (modelled),in call to `NSObject.init` (modelled),assigned,when calling `MyClass2.setC:` here,parameter `self` of MyClass2.setC:,assigned,assignment of c_obj->_a part of the trace starts here,allocated by call to `alloc` (modelled),in call to `NSObject.init` (modelled),assigned,when calling `MyClass3.setA:` here,parameter `self` of MyClass3.setA:,assigned,retain cycle here]
codetoanalyze/objc/pulse/retain_cycles/RetainCyclePropertyInProtocol.m, MyCustomViewController.loadViewRetainCycle_bad, 2, RETAIN_CYCLE, no_bucket, ERROR, [assignment of &self part of the trace starts here,allocated by call to `alloc` (modelled),when calling `MyCustomView.initWithStrongDelegate:` here,parameter `self` of MyCustomView.initWithStrongDelegate:,assigned,assignment of self->_view part of the trace starts here,parameter `self` of MyCustomViewController.loadViewRetainCycle_bad,when calling `MyCustomViewController.setView:` here,parameter `self` of MyCustomViewController.setView:,assigned,retain cycle here]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#import <UIKit/UIKit.h>

@interface TestView : UIView
@end

@implementation TestView {
UIView* _lastTouchedView;
UIView* _timeRangeSelectorView;
}

- (void)_newGestureTypeFromGesture:(UIGestureRecognizer*)gesture {
UIView* hitViewInScrubber = [self hitTest:[gesture locationInView:self]
withEvent:nil];
_lastTouchedView = hitViewInScrubber;
}

- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent*)event {
UIView* const hitView = [super hitTest:point withEvent:event];
if ((!hitView || hitView == self) && [self pointInside:point
withEvent:event]) {
return _timeRangeSelectorView;
}
return hitView;
}
@end

0 comments on commit 2880cfe

Please sign in to comment.