Skip to content

Fix possible memory leak in CLUUserInteractionModule because of connected gesture recognizer #5

@Geek-1001

Description

@Geek-1001

Description

There is a #warning in CLUUserInteractionModule class in startRecording method

- (void)startRecording {
    if (!self.isRecording) {
        [super startRecording];
        [_gestureRecognizer setObserverDelegate:self];
        #warning If some window will be destroyed how to deattach gesture recognizer from it? Possible memory leak!
        [[[UIApplication sharedApplication] keyWindow] addGestureRecognizer:_gestureRecognizer];
    }
}

We're connecting gesture recognizer to specific window [[UIApplication sharedApplication] keyWindow].

Problems

  • Key window could change during the lifetime of the app.
  • What if current key window is different from current active window (in terms of touch events) at the moment

References

A window is considered the key window when it is currently receiving keyboard and non touch-related events. Whereas touch events are delivered to the window in which the touch occurred, events that don’t have an associated coordinate value are delivered to the key window. Only one window at a time can be key

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions