Skip to content

Commit 10c41ec

Browse files
committed
added a test to reproduce the crash from flutter/flutter#56996
1 parent ed035d5 commit 10c41ec

17 files changed

Lines changed: 414 additions & 19 deletions

File tree

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
// Autogenerated from Pigeon (v0.1.0-experimental.9), do not edit directly.
2+
// See also: https://pub.dev/packages/pigeon
3+
4+
package dev.flutter.aaclarke.pigeon;
5+
6+
import io.flutter.plugin.common.BasicMessageChannel;
7+
import io.flutter.plugin.common.BinaryMessenger;
8+
import io.flutter.plugin.common.StandardMessageCodec;
9+
import java.util.HashMap;
10+
11+
/** Generated class from Pigeon. */
12+
public class Dartle {
13+
14+
/** Generated class from Pigeon that represents data sent in messages. */
15+
public static class SearchReply {
16+
private String result;
17+
18+
public String getResult() {
19+
return result;
20+
}
21+
22+
public void setResult(String setterArg) {
23+
this.result = setterArg;
24+
}
25+
26+
private String error;
27+
28+
public String getError() {
29+
return error;
30+
}
31+
32+
public void setError(String setterArg) {
33+
this.error = setterArg;
34+
}
35+
36+
HashMap toMap() {
37+
HashMap<String, Object> toMapResult = new HashMap<String, Object>();
38+
toMapResult.put("result", result);
39+
toMapResult.put("error", error);
40+
return toMapResult;
41+
}
42+
43+
static SearchReply fromMap(HashMap map) {
44+
SearchReply fromMapResult = new SearchReply();
45+
fromMapResult.result = (String) map.get("result");
46+
fromMapResult.error = (String) map.get("error");
47+
return fromMapResult;
48+
}
49+
}
50+
51+
/** Generated class from Pigeon that represents data sent in messages. */
52+
public static class SearchRequest {
53+
private String query;
54+
55+
public String getQuery() {
56+
return query;
57+
}
58+
59+
public void setQuery(String setterArg) {
60+
this.query = setterArg;
61+
}
62+
63+
private Long anInt;
64+
65+
public Long getAnInt() {
66+
return anInt;
67+
}
68+
69+
public void setAnInt(Long setterArg) {
70+
this.anInt = setterArg;
71+
}
72+
73+
private Boolean aBool;
74+
75+
public Boolean getABool() {
76+
return aBool;
77+
}
78+
79+
public void setABool(Boolean setterArg) {
80+
this.aBool = setterArg;
81+
}
82+
83+
HashMap toMap() {
84+
HashMap<String, Object> toMapResult = new HashMap<String, Object>();
85+
toMapResult.put("query", query);
86+
toMapResult.put("anInt", anInt);
87+
toMapResult.put("aBool", aBool);
88+
return toMapResult;
89+
}
90+
91+
static SearchRequest fromMap(HashMap map) {
92+
SearchRequest fromMapResult = new SearchRequest();
93+
fromMapResult.query = (String) map.get("query");
94+
fromMapResult.anInt =
95+
(map.get("anInt") instanceof Integer)
96+
? (Integer) map.get("anInt")
97+
: (Long) map.get("anInt");
98+
fromMapResult.aBool = (Boolean) map.get("aBool");
99+
return fromMapResult;
100+
}
101+
}
102+
103+
/** Generated class from Pigeon that represents data sent in messages. */
104+
public static class Nested {
105+
private SearchRequest request;
106+
107+
public SearchRequest getRequest() {
108+
return request;
109+
}
110+
111+
public void setRequest(SearchRequest setterArg) {
112+
this.request = setterArg;
113+
}
114+
115+
HashMap toMap() {
116+
HashMap<String, Object> toMapResult = new HashMap<String, Object>();
117+
toMapResult.put("request", request);
118+
return toMapResult;
119+
}
120+
121+
static Nested fromMap(HashMap map) {
122+
Nested fromMapResult = new Nested();
123+
fromMapResult.request = (SearchRequest) map.get("request");
124+
return fromMapResult;
125+
}
126+
}
127+
128+
/** Generated class from Pigeon that represents Flutter messages that can be called from Java. */
129+
public static class FlutterSearchApi {
130+
private BinaryMessenger binaryMessenger;
131+
132+
public FlutterSearchApi(BinaryMessenger argBinaryMessenger) {
133+
this.binaryMessenger = argBinaryMessenger;
134+
}
135+
136+
public interface Reply<T> {
137+
void reply(T reply);
138+
}
139+
140+
public void search(SearchRequest argInput, Reply<SearchReply> callback) {
141+
BasicMessageChannel<Object> channel =
142+
new BasicMessageChannel<Object>(
143+
binaryMessenger,
144+
"dev.flutter.pigeon.FlutterSearchApi.search",
145+
new StandardMessageCodec());
146+
HashMap inputMap = argInput.toMap();
147+
channel.send(
148+
inputMap,
149+
new BasicMessageChannel.Reply<Object>() {
150+
public void reply(Object channelReply) {
151+
HashMap outputMap = (HashMap) channelReply;
152+
SearchReply output = SearchReply.fromMap(outputMap);
153+
callback.reply(output);
154+
}
155+
});
156+
}
157+
}
158+
159+
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
160+
public interface NestedApi {
161+
SearchReply search(Nested arg);
162+
163+
/** Sets up an instance of `NestedApi` to handle messages through the `binaryMessenger` */
164+
public static void setup(BinaryMessenger binaryMessenger, NestedApi api) {
165+
{
166+
BasicMessageChannel<Object> channel =
167+
new BasicMessageChannel<Object>(
168+
binaryMessenger, "dev.flutter.pigeon.NestedApi.search", new StandardMessageCodec());
169+
channel.setMessageHandler(
170+
new BasicMessageChannel.MessageHandler<Object>() {
171+
public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
172+
Nested input = Nested.fromMap((HashMap) message);
173+
HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>();
174+
try {
175+
SearchReply output = api.search(input);
176+
wrapped.put("result", output.toMap());
177+
} catch (Exception exception) {
178+
wrapped.put("error", wrapError(exception));
179+
}
180+
reply.reply(wrapped);
181+
}
182+
});
183+
}
184+
}
185+
}
186+
187+
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
188+
public interface Api {
189+
SearchReply search(SearchRequest arg);
190+
191+
/** Sets up an instance of `Api` to handle messages through the `binaryMessenger` */
192+
public static void setup(BinaryMessenger binaryMessenger, Api api) {
193+
{
194+
BasicMessageChannel<Object> channel =
195+
new BasicMessageChannel<Object>(
196+
binaryMessenger, "dev.flutter.pigeon.Api.search", new StandardMessageCodec());
197+
channel.setMessageHandler(
198+
new BasicMessageChannel.MessageHandler<Object>() {
199+
public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
200+
SearchRequest input = SearchRequest.fromMap((HashMap) message);
201+
HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>();
202+
try {
203+
SearchReply output = api.search(input);
204+
wrapped.put("result", output.toMap());
205+
} catch (Exception exception) {
206+
wrapped.put("error", wrapError(exception));
207+
}
208+
reply.reply(wrapped);
209+
}
210+
});
211+
}
212+
}
213+
}
214+
215+
private static HashMap wrapError(Exception exception) {
216+
HashMap<String, Object> errorMap = new HashMap<String, Object>();
217+
errorMap.put("message", exception.toString());
218+
errorMap.put("code", null);
219+
errorMap.put("details", null);
220+
return errorMap;
221+
}
222+
}

‎packages/pigeon/e2e_tests/test_objc/ios/Runner.xcodeproj/project.pbxproj‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
0D74DF16246C6DAB00400EBA /* MyEngineControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D74DF15246C6DAB00400EBA /* MyEngineControl.m */; };
11+
0D74DF19246C780F00400EBA /* MyPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D74DF18246C780F00400EBA /* MyPlugin.m */; };
1012
0D89130E23C8F951005E0326 /* dartle.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D89130D23C8F951005E0326 /* dartle.m */; };
1113
0D89131123C8FB14005E0326 /* MyFlutterViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D89131023C8FB14005E0326 /* MyFlutterViewController.m */; };
1214
0D89131423C8FCD2005E0326 /* MyApi.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D89131323C8FCD2005E0326 /* MyApi.m */; };
@@ -46,6 +48,10 @@
4648
/* End PBXCopyFilesBuildPhase section */
4749

4850
/* Begin PBXFileReference section */
51+
0D74DF14246C6DAB00400EBA /* MyEngineControl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MyEngineControl.h; sourceTree = "<group>"; };
52+
0D74DF15246C6DAB00400EBA /* MyEngineControl.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MyEngineControl.m; sourceTree = "<group>"; };
53+
0D74DF17246C780F00400EBA /* MyPlugin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MyPlugin.h; sourceTree = "<group>"; };
54+
0D74DF18246C780F00400EBA /* MyPlugin.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MyPlugin.m; sourceTree = "<group>"; };
4955
0D89130C23C8F951005E0326 /* dartle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dartle.h; sourceTree = "<group>"; };
5056
0D89130D23C8F951005E0326 /* dartle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = dartle.m; sourceTree = "<group>"; };
5157
0D89130F23C8FB14005E0326 /* MyFlutterViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MyFlutterViewController.h; sourceTree = "<group>"; };
@@ -175,6 +181,10 @@
175181
0D89131323C8FCD2005E0326 /* MyApi.m */,
176182
0DA878AE2453583800622EF2 /* MyNestedApi.h */,
177183
0DA878AF2453583800622EF2 /* MyNestedApi.m */,
184+
0D74DF14246C6DAB00400EBA /* MyEngineControl.h */,
185+
0D74DF15246C6DAB00400EBA /* MyEngineControl.m */,
186+
0D74DF17246C780F00400EBA /* MyPlugin.h */,
187+
0D74DF18246C780F00400EBA /* MyPlugin.m */,
178188
);
179189
path = Runner;
180190
sourceTree = "<group>";
@@ -371,12 +381,14 @@
371381
buildActionMask = 2147483647;
372382
files = (
373383
0D89131423C8FCD2005E0326 /* MyApi.m in Sources */,
384+
0D74DF16246C6DAB00400EBA /* MyEngineControl.m in Sources */,
374385
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */,
375386
97C146F31CF9000F007C117D /* main.m in Sources */,
376387
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
377388
0D89130E23C8F951005E0326 /* dartle.m in Sources */,
378389
0D89131123C8FB14005E0326 /* MyFlutterViewController.m in Sources */,
379390
0DA878B02453583800622EF2 /* MyNestedApi.m in Sources */,
391+
0D74DF19246C780F00400EBA /* MyPlugin.m in Sources */,
380392
);
381393
runOnlyForDeploymentPostprocessing = 0;
382394
};

‎packages/pigeon/e2e_tests/test_objc/ios/Runner/MyApi.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
NS_ASSUME_NONNULL_BEGIN
55

66
/// Implementation of the Pigeon generated interface Api.
7-
@interface MyApi : NSObject<ACApi>
7+
@interface MyApi : NSObject <ACApi>
88
@end
99

1010
NS_ASSUME_NONNULL_END
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#import <Foundation/Foundation.h>
6+
#import "dartle.h"
7+
8+
NS_ASSUME_NONNULL_BEGIN
9+
10+
@interface MyEngineControl : NSObject <ACEngineControl>
11+
12+
@end
13+
14+
NS_ASSUME_NONNULL_END
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#import "MyEngineControl.h"
6+
#import "MyPlugin.h"
7+
8+
#if !__has_feature(objc_arc)
9+
#error ARC must be enabled!
10+
#endif
11+
12+
@implementation MyEngineControl
13+
- (void)createDestroyContextThenDeallocEngine:(FlutterError* _Nullable* _Nonnull)error {
14+
@autoreleasepool {
15+
FlutterEngine* engine =
16+
[[FlutterEngine alloc] initWithName:@"createDestroyContextThenDeallocEngine"];
17+
[engine run];
18+
[MyPlugin registerWithRegistrar:[engine registrarForPlugin:@"MyPlugin"]];
19+
[engine destroyContext];
20+
}
21+
}
22+
@end

‎packages/pigeon/e2e_tests/test_objc/ios/Runner/MyFlutterViewController.m‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#import "MyFlutterViewController.h"
22
#import "MyApi.h"
3+
#import "MyEngineControl.h"
34
#import "MyNestedApi.h"
45
#import "dartle.h"
56

@@ -12,6 +13,7 @@ - (void)viewDidLoad {
1213
[super viewDidLoad];
1314
ACApiSetup(self.engine.binaryMessenger, [[MyApi alloc] init]);
1415
ACNestedApiSetup(self.engine.binaryMessenger, [[MyNestedApi alloc] init]);
16+
ACEngineControlSetup(self.engine.binaryMessenger, [[MyEngineControl alloc] init]);
1517
}
1618

1719
@end

‎packages/pigeon/e2e_tests/test_objc/ios/Runner/MyNestedApi.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
NS_ASSUME_NONNULL_BEGIN
55

66
/// Implementation of the Pigeon generated interface NestedApi.
7-
@interface MyNestedApi : NSObject<ACNestedApi>
7+
@interface MyNestedApi : NSObject <ACNestedApi>
88
- (ACSearchReply *)search:(ACNested *)input error:(FlutterError *_Nullable *_Nonnull)error;
99
@end
1010

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#import <Flutter/Flutter.h>
6+
#import "MyApi.h"
7+
8+
NS_ASSUME_NONNULL_BEGIN
9+
10+
@interface MyPlugin : NSObject<FlutterPlugin, ACApi>
11+
- (instancetype)initWithRegistrar:(nonnull NSObject<FlutterPluginRegistrar> *)registrar;
12+
@end
13+
14+
NS_ASSUME_NONNULL_END
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#import "MyPlugin.h"
6+
7+
8+
@implementation MyPlugin
9+
10+
+ (void)registerWithRegistrar:(nonnull NSObject<FlutterPluginRegistrar> *)registrar {
11+
MyPlugin* instance = [[MyPlugin alloc] initWithRegistrar:registrar];
12+
[registrar publish:instance];
13+
ACApiSetup(registrar.messenger, instance);
14+
}
15+
16+
- (instancetype)initWithRegistrar:(nonnull NSObject<FlutterPluginRegistrar> *)registrar {
17+
self = [super init];
18+
return self;
19+
}
20+
21+
- (nonnull ACSearchReply *)search:(nonnull ACSearchRequest *)input error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
22+
ACSearchReply* reply = [[ACSearchReply alloc] init];
23+
return reply;
24+
}
25+
26+
- (void)detachFromEngineForRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
27+
ACApiSetup(registrar.messenger, nil);
28+
}
29+
30+
@end

‎packages/pigeon/e2e_tests/test_objc/ios/Runner/dartle.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ NS_ASSUME_NONNULL_BEGIN
2626
@property(nonatomic, strong, nullable) ACSearchRequest *request;
2727
@end
2828

29+
@protocol ACEngineControl
30+
- (void)createDestroyContextThenDeallocEngine:(FlutterError *_Nullable *_Nonnull)error;
31+
@end
32+
33+
extern void ACEngineControlSetup(id<FlutterBinaryMessenger> binaryMessenger,
34+
id<ACEngineControl> api);
35+
2936
@interface ACFlutterSearchApi : NSObject
3037
- (instancetype)initWithBinaryMessenger:(id<FlutterBinaryMessenger>)binaryMessenger;
3138
- (void)search:(ACSearchRequest *)input completion:(void (^)(ACSearchReply *, NSError *))completion;

0 commit comments

Comments
 (0)