KeyboardKit: Possible Memory Leak On Keyboard Kit

I tried both KeyboardKitDemoKeyboard and KeyboardKitDemoKeyboard_SwiftUI. When running, open debug session and try change keyboard many times (from keyboard kit demo to native and vice versa). Notice in debug session memory will always increase every time keyboard kit active (memory increased around 1.3 - 2 MB).

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17

Most upvoted comments

I aim to fix this and the SwiftUI dark appearance color bugs in a patch next week.

Ok, I have sat with this for an hour now and can reproduce the exakt behavior that @albilaga reports.

In UIKit, instruments point out DemoButton and RepeatingGestureRecognizer when I check for memory leaks. That doesn’t mean that the gesture must be the one containing the leak, only that it’s not released since the button it not released.

However, I cannot find the problem. I see no obvious missing weak selves or potential locks, except the gesture recognizer which refers to itself, but the delegate is weal.

In SwiftUI, the memory leak graph is a lot more noisy. I haven’t been able to sit more with it, though.

The leak has been solved 🎉 The problem was that the action that was passed into the repeating gesture recognizer had a reference to the button argument, which wasn’t made weak before being passed into the action.

However, I still see a memory leak when I switch keyboards, but it doesn’t seem to be caused by any code in KeyboardKit:

image

@fukuru @albilaga and the rest of you. If any of you could verify that the problem is indeed solved, I could release this as a patch instead of waiting until the next version.

I may have found the reason for this. The input view controller has a keyboard context, which refers back to the controller. I will try to make the contex’s controller reference unowned to see if it solves the problem.

Hi! My gut feeling says that there is a missing weak self or weak/unowned dependency somewhere. I am swamped with work and another project, but will try to find time to fix this during December.