Commit 4e8fcf3
Fix retain cycle in LiveViewCoordinator (#1455)
* Fix retain cycle in LiveViewCoordinator
`LiveViewCoordinator` is initialised from `LiveSessionCoordinator`, which
gets passed in as a parameter to `init` and then retained by the view
coordinator. This causes a retain cycle.
Additionally, this is also retained by the `handleEvent` as `session`
was used directly in the closure, which then retained it.
This commit fixes both by using a weak reference from the view coordinator
to the session coordinator, and accessing the session via the weak `self`
reference.
* Follow-up robustness fix to avoid rare runtime crash
* Follow-up robustness fix, removing `unowned self`
* Update Sources/LiveViewNative/Coordinators/LiveViewCoordinator.swift
Co-authored-by: Carson Katri <[email protected]>
Signed-off-by: Adrian Schönig <[email protected]>
* Update CHANGELOG.md
---------
Signed-off-by: Adrian Schönig <[email protected]>
Co-authored-by: Carson Katri <[email protected]>1 parent e2c4408 commit 4e8fcf3
File tree
3 files changed
+12
-7
lines changed- Sources/LiveViewNative/Coordinators
3 files changed
+12
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
421 | 421 | | |
422 | 422 | | |
423 | 423 | | |
| 424 | + | |
424 | 425 | | |
425 | 426 | | |
426 | | - | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
427 | 430 | | |
428 | 431 | | |
429 | 432 | | |
| |||
505 | 508 | | |
506 | 509 | | |
507 | 510 | | |
508 | | - | |
| 511 | + | |
509 | 512 | | |
510 | 513 | | |
511 | 514 | | |
512 | 515 | | |
513 | | - | |
| 516 | + | |
514 | 517 | | |
515 | 518 | | |
516 | 519 | | |
| |||
Lines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
| 71 | + | |
71 | 72 | | |
72 | | - | |
73 | | - | |
| 73 | + | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
0 commit comments