Sergiy Dubovik b7264de08d [macos] FlutterKeyboardManager memory leak fix (flutter/engine#48824)
We are embedding Flutter into MacOS app, and noticed that there is a
leak. `leaks` tool says there is a cycle reference:

```
12 (2.11K) ROOT CYCLE: <FlutterKeyboardManager 0x29ec55f40> [80]
       8 (432 bytes) __strong _primaryResponders --> ROOT CYCLE: <NSMutableArray 0x29ec560a0> [64]
          7 (368 bytes) ROOT CYCLE: <NSMutableArray (Storage) 0x29ec56140> [32]
             4 (224 bytes) ROOT CYCLE: <FlutterEmbedderKeyResponder 0x29ec56310> [80]
                1 (48 bytes) __strong _sendEvent --> ROOT CYCLE: <__NSMallocBlock__ 0x29ec56360> [48]
                   __strong [capture] --> CYCLE BACK TO <FlutterKeyboardManager 0x29ec55f40> [80]
                1 (48 bytes) __strong _pendingResponses --> <NSMutableDictionary 0x29ec563c0> [48]
                1 (48 bytes) __strong _pressingRecords --> <NSMutableDictionary 0x29ec56390> [48]
             2 (112 bytes) <FlutterChannelKeyResponder 0x29ec56450> [48]
                1 (64 bytes) __strong _channel --> <FlutterBasicMessageChannel 0x29ec564e0> [64]
       2 (1.55K) __strong _layoutMap --> <NSMutableDictionary 0x29ec56630> [48]
          1 (1.50K) <NSMutableDictionary (Storage) 0x123c34a00> [1536]
       1 (64 bytes) __strong _pendingEvents --> <NSMutableArray 0x29ec565f0> [64]
```

This patch uses `weak` pointer to `self` instead of implicit `strong`.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I added new tests to check the change I am making or feature I am
adding, or the PR is [test-exempt]. See [testing the engine] for
instructions on writing and running engine tests.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.
2023-12-20 09:04:10 -08:00
..