This repository was archived by the owner on Feb 22, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +27
-5
lines changed
packages/camera/camera_avfoundation Expand file tree Collapse file tree 4 files changed +27
-5
lines changed Original file line number Diff line number Diff line change
1
+ ## 0.9.8+5
2
+
3
+ * Fixes a regression introduced in 0.9.8+4 where the stream handler is not set.
4
+
1
5
## 0.9.8+4
2
6
3
7
* Fixes a crash due to sending orientation change events when the engine is torn down.
Original file line number Diff line number Diff line change @@ -63,4 +63,20 @@ - (void)testSetStreamHandler_shouldDispatchToMainThreadIfCalledFromBackgroundThr
63
63
[self waitForExpectationsWithTimeout: 1 handler: nil ];
64
64
}
65
65
66
+ - (void )testEventChannel_shouldBeKeptAliveWhenDispatchingBackToMainThread {
67
+ XCTestExpectation *expectation =
68
+ [self expectationWithDescription: @" Completion should be called." ];
69
+ dispatch_async (dispatch_queue_create (" test" , NULL ), ^{
70
+ FLTThreadSafeEventChannel *channel = [[FLTThreadSafeEventChannel alloc ]
71
+ initWithEventChannel: OCMClassMock ([FlutterEventChannel class ])];
72
+
73
+ [channel setStreamHandler: OCMOCK_ANY
74
+ completion: ^{
75
+ [expectation fulfill ];
76
+ }];
77
+ });
78
+
79
+ [self waitForExpectationsWithTimeout: 1 handler: nil ];
80
+ }
81
+
66
82
@end
Original file line number Diff line number Diff line change @@ -21,11 +21,13 @@ - (instancetype)initWithEventChannel:(FlutterEventChannel *)channel {
21
21
22
22
- (void )setStreamHandler : (NSObject <FlutterStreamHandler> *)handler
23
23
completion : (void (^)(void ))completion {
24
- __weak typeof (self) weakSelf = self;
24
+ // WARNING: Should not use weak self, because FLTThreadSafeEventChannel is a local variable
25
+ // (retained within call stack, but not in the heap). FLTEnsureToRunOnMainQueue may trigger a
26
+ // context switch (when calling from background thread), in which case using weak self will always
27
+ // result in a nil self. Alternative to using strong self, we can also create a local strong
28
+ // variable to be captured by this block.
25
29
FLTEnsureToRunOnMainQueue (^{
26
- typeof (self) strongSelf = weakSelf;
27
- if (!strongSelf) return ;
28
- [strongSelf.channel setStreamHandler: handler];
30
+ [self .channel setStreamHandler: handler];
29
31
completion ();
30
32
});
31
33
}
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ name: camera_avfoundation
2
2
description : iOS implementation of the camera plugin.
3
3
repository : https://github.com/flutter/plugins/tree/main/packages/camera/camera_avfoundation
4
4
issue_tracker : https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
5
- version : 0.9.8+4
5
+ version : 0.9.8+5
6
6
7
7
environment :
8
8
sdk : " >=2.14.0 <3.0.0"
You can’t perform that action at this time.
0 commit comments