Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit ff3ed74

Browse files
authored
fixed detach from engine logic (#2759)
1 parent 0dd8414 commit ff3ed74

File tree

6 files changed

+166
-122
lines changed

6 files changed

+166
-122
lines changed

packages/video_player/video_player/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.10.11
2+
3+
* iOS: Fixed crash when detaching from a dying engine.
4+
* Android: Fixed exception when detaching from any engine.
5+
16
## 0.10.10
27

38
* Migrated to [pigeon](https://pub.dev/packages/pigeon).

packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java

Lines changed: 153 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Autogenerated from Pigeon (v0.1.0-experimental.10), do not edit directly.
1+
// Autogenerated from Pigeon (v0.1.0-experimental.11), do not edit directly.
22
// See also: https://pub.dev/packages/pigeon
33

44
package io.flutter.plugins.videoplayer;
@@ -251,187 +251,223 @@ public static void setup(BinaryMessenger binaryMessenger, VideoPlayerApi api) {
251251
binaryMessenger,
252252
"dev.flutter.pigeon.VideoPlayerApi.initialize",
253253
new StandardMessageCodec());
254-
channel.setMessageHandler(
255-
new BasicMessageChannel.MessageHandler<Object>() {
256-
public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
257-
HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>();
258-
try {
259-
api.initialize();
260-
wrapped.put("result", null);
261-
} catch (Exception exception) {
262-
wrapped.put("error", wrapError(exception));
254+
if (api != null) {
255+
channel.setMessageHandler(
256+
new BasicMessageChannel.MessageHandler<Object>() {
257+
public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
258+
HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>();
259+
try {
260+
api.initialize();
261+
wrapped.put("result", null);
262+
} catch (Exception exception) {
263+
wrapped.put("error", wrapError(exception));
264+
}
265+
reply.reply(wrapped);
263266
}
264-
reply.reply(wrapped);
265-
}
266-
});
267+
});
268+
} else {
269+
channel.setMessageHandler(null);
270+
}
267271
}
268272
{
269273
BasicMessageChannel<Object> channel =
270274
new BasicMessageChannel<Object>(
271275
binaryMessenger,
272276
"dev.flutter.pigeon.VideoPlayerApi.create",
273277
new StandardMessageCodec());
274-
channel.setMessageHandler(
275-
new BasicMessageChannel.MessageHandler<Object>() {
276-
public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
277-
CreateMessage input = CreateMessage.fromMap((HashMap) message);
278-
HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>();
279-
try {
280-
TextureMessage output = api.create(input);
281-
wrapped.put("result", output.toMap());
282-
} catch (Exception exception) {
283-
wrapped.put("error", wrapError(exception));
278+
if (api != null) {
279+
channel.setMessageHandler(
280+
new BasicMessageChannel.MessageHandler<Object>() {
281+
public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
282+
CreateMessage input = CreateMessage.fromMap((HashMap) message);
283+
HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>();
284+
try {
285+
TextureMessage output = api.create(input);
286+
wrapped.put("result", output.toMap());
287+
} catch (Exception exception) {
288+
wrapped.put("error", wrapError(exception));
289+
}
290+
reply.reply(wrapped);
284291
}
285-
reply.reply(wrapped);
286-
}
287-
});
292+
});
293+
} else {
294+
channel.setMessageHandler(null);
295+
}
288296
}
289297
{
290298
BasicMessageChannel<Object> channel =
291299
new BasicMessageChannel<Object>(
292300
binaryMessenger,
293301
"dev.flutter.pigeon.VideoPlayerApi.dispose",
294302
new StandardMessageCodec());
295-
channel.setMessageHandler(
296-
new BasicMessageChannel.MessageHandler<Object>() {
297-
public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
298-
TextureMessage input = TextureMessage.fromMap((HashMap) message);
299-
HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>();
300-
try {
301-
api.dispose(input);
302-
wrapped.put("result", null);
303-
} catch (Exception exception) {
304-
wrapped.put("error", wrapError(exception));
303+
if (api != null) {
304+
channel.setMessageHandler(
305+
new BasicMessageChannel.MessageHandler<Object>() {
306+
public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
307+
TextureMessage input = TextureMessage.fromMap((HashMap) message);
308+
HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>();
309+
try {
310+
api.dispose(input);
311+
wrapped.put("result", null);
312+
} catch (Exception exception) {
313+
wrapped.put("error", wrapError(exception));
314+
}
315+
reply.reply(wrapped);
305316
}
306-
reply.reply(wrapped);
307-
}
308-
});
317+
});
318+
} else {
319+
channel.setMessageHandler(null);
320+
}
309321
}
310322
{
311323
BasicMessageChannel<Object> channel =
312324
new BasicMessageChannel<Object>(
313325
binaryMessenger,
314326
"dev.flutter.pigeon.VideoPlayerApi.setLooping",
315327
new StandardMessageCodec());
316-
channel.setMessageHandler(
317-
new BasicMessageChannel.MessageHandler<Object>() {
318-
public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
319-
LoopingMessage input = LoopingMessage.fromMap((HashMap) message);
320-
HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>();
321-
try {
322-
api.setLooping(input);
323-
wrapped.put("result", null);
324-
} catch (Exception exception) {
325-
wrapped.put("error", wrapError(exception));
328+
if (api != null) {
329+
channel.setMessageHandler(
330+
new BasicMessageChannel.MessageHandler<Object>() {
331+
public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
332+
LoopingMessage input = LoopingMessage.fromMap((HashMap) message);
333+
HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>();
334+
try {
335+
api.setLooping(input);
336+
wrapped.put("result", null);
337+
} catch (Exception exception) {
338+
wrapped.put("error", wrapError(exception));
339+
}
340+
reply.reply(wrapped);
326341
}
327-
reply.reply(wrapped);
328-
}
329-
});
342+
});
343+
} else {
344+
channel.setMessageHandler(null);
345+
}
330346
}
331347
{
332348
BasicMessageChannel<Object> channel =
333349
new BasicMessageChannel<Object>(
334350
binaryMessenger,
335351
"dev.flutter.pigeon.VideoPlayerApi.setVolume",
336352
new StandardMessageCodec());
337-
channel.setMessageHandler(
338-
new BasicMessageChannel.MessageHandler<Object>() {
339-
public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
340-
VolumeMessage input = VolumeMessage.fromMap((HashMap) message);
341-
HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>();
342-
try {
343-
api.setVolume(input);
344-
wrapped.put("result", null);
345-
} catch (Exception exception) {
346-
wrapped.put("error", wrapError(exception));
353+
if (api != null) {
354+
channel.setMessageHandler(
355+
new BasicMessageChannel.MessageHandler<Object>() {
356+
public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
357+
VolumeMessage input = VolumeMessage.fromMap((HashMap) message);
358+
HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>();
359+
try {
360+
api.setVolume(input);
361+
wrapped.put("result", null);
362+
} catch (Exception exception) {
363+
wrapped.put("error", wrapError(exception));
364+
}
365+
reply.reply(wrapped);
347366
}
348-
reply.reply(wrapped);
349-
}
350-
});
367+
});
368+
} else {
369+
channel.setMessageHandler(null);
370+
}
351371
}
352372
{
353373
BasicMessageChannel<Object> channel =
354374
new BasicMessageChannel<Object>(
355375
binaryMessenger,
356376
"dev.flutter.pigeon.VideoPlayerApi.play",
357377
new StandardMessageCodec());
358-
channel.setMessageHandler(
359-
new BasicMessageChannel.MessageHandler<Object>() {
360-
public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
361-
TextureMessage input = TextureMessage.fromMap((HashMap) message);
362-
HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>();
363-
try {
364-
api.play(input);
365-
wrapped.put("result", null);
366-
} catch (Exception exception) {
367-
wrapped.put("error", wrapError(exception));
378+
if (api != null) {
379+
channel.setMessageHandler(
380+
new BasicMessageChannel.MessageHandler<Object>() {
381+
public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
382+
TextureMessage input = TextureMessage.fromMap((HashMap) message);
383+
HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>();
384+
try {
385+
api.play(input);
386+
wrapped.put("result", null);
387+
} catch (Exception exception) {
388+
wrapped.put("error", wrapError(exception));
389+
}
390+
reply.reply(wrapped);
368391
}
369-
reply.reply(wrapped);
370-
}
371-
});
392+
});
393+
} else {
394+
channel.setMessageHandler(null);
395+
}
372396
}
373397
{
374398
BasicMessageChannel<Object> channel =
375399
new BasicMessageChannel<Object>(
376400
binaryMessenger,
377401
"dev.flutter.pigeon.VideoPlayerApi.position",
378402
new StandardMessageCodec());
379-
channel.setMessageHandler(
380-
new BasicMessageChannel.MessageHandler<Object>() {
381-
public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
382-
TextureMessage input = TextureMessage.fromMap((HashMap) message);
383-
HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>();
384-
try {
385-
PositionMessage output = api.position(input);
386-
wrapped.put("result", output.toMap());
387-
} catch (Exception exception) {
388-
wrapped.put("error", wrapError(exception));
403+
if (api != null) {
404+
channel.setMessageHandler(
405+
new BasicMessageChannel.MessageHandler<Object>() {
406+
public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
407+
TextureMessage input = TextureMessage.fromMap((HashMap) message);
408+
HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>();
409+
try {
410+
PositionMessage output = api.position(input);
411+
wrapped.put("result", output.toMap());
412+
} catch (Exception exception) {
413+
wrapped.put("error", wrapError(exception));
414+
}
415+
reply.reply(wrapped);
389416
}
390-
reply.reply(wrapped);
391-
}
392-
});
417+
});
418+
} else {
419+
channel.setMessageHandler(null);
420+
}
393421
}
394422
{
395423
BasicMessageChannel<Object> channel =
396424
new BasicMessageChannel<Object>(
397425
binaryMessenger,
398426
"dev.flutter.pigeon.VideoPlayerApi.seekTo",
399427
new StandardMessageCodec());
400-
channel.setMessageHandler(
401-
new BasicMessageChannel.MessageHandler<Object>() {
402-
public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
403-
PositionMessage input = PositionMessage.fromMap((HashMap) message);
404-
HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>();
405-
try {
406-
api.seekTo(input);
407-
wrapped.put("result", null);
408-
} catch (Exception exception) {
409-
wrapped.put("error", wrapError(exception));
428+
if (api != null) {
429+
channel.setMessageHandler(
430+
new BasicMessageChannel.MessageHandler<Object>() {
431+
public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
432+
PositionMessage input = PositionMessage.fromMap((HashMap) message);
433+
HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>();
434+
try {
435+
api.seekTo(input);
436+
wrapped.put("result", null);
437+
} catch (Exception exception) {
438+
wrapped.put("error", wrapError(exception));
439+
}
440+
reply.reply(wrapped);
410441
}
411-
reply.reply(wrapped);
412-
}
413-
});
442+
});
443+
} else {
444+
channel.setMessageHandler(null);
445+
}
414446
}
415447
{
416448
BasicMessageChannel<Object> channel =
417449
new BasicMessageChannel<Object>(
418450
binaryMessenger,
419451
"dev.flutter.pigeon.VideoPlayerApi.pause",
420452
new StandardMessageCodec());
421-
channel.setMessageHandler(
422-
new BasicMessageChannel.MessageHandler<Object>() {
423-
public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
424-
TextureMessage input = TextureMessage.fromMap((HashMap) message);
425-
HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>();
426-
try {
427-
api.pause(input);
428-
wrapped.put("result", null);
429-
} catch (Exception exception) {
430-
wrapped.put("error", wrapError(exception));
453+
if (api != null) {
454+
channel.setMessageHandler(
455+
new BasicMessageChannel.MessageHandler<Object>() {
456+
public void onMessage(Object message, BasicMessageChannel.Reply<Object> reply) {
457+
TextureMessage input = TextureMessage.fromMap((HashMap) message);
458+
HashMap<String, HashMap> wrapped = new HashMap<String, HashMap>();
459+
try {
460+
api.pause(input);
461+
wrapped.put("result", null);
462+
} catch (Exception exception) {
463+
wrapped.put("error", wrapError(exception));
464+
}
465+
reply.reply(wrapped);
431466
}
432-
reply.reply(wrapped);
433-
}
434-
});
467+
});
468+
} else {
469+
channel.setMessageHandler(null);
470+
}
435471
}
436472
}
437473
}

packages/video_player/video_player/ios/Classes/FLTVideoPlayerPlugin.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,10 @@ - (void)detachFromEngineForRegistrar:(NSObject<FlutterPluginRegistrar>*)registra
451451
[player disposeSansEventChannel];
452452
}
453453
[_players removeAllObjects];
454-
FLTVideoPlayerApiSetup(registrar.messenger, nil);
454+
// TODO(57151): This should be commented out when 57151's fix lands on stable.
455+
// This is the correct behavior we never did it in the past and the engine
456+
// doesn't currently support it.
457+
// FLTVideoPlayerApiSetup(registrar.messenger, nil);
455458
}
456459

457460
- (FLTTextureMessage*)onPlayerSetup:(FLTVideoPlayer*)player

packages/video_player/video_player/ios/Classes/messages.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Autogenerated from Pigeon (v0.1.0-experimental.10), do not edit directly.
1+
// Autogenerated from Pigeon (v0.1.0-experimental.11), do not edit directly.
22
// See also: https://pub.dev/packages/pigeon
33
#import <Foundation/Foundation.h>
44
@protocol FlutterBinaryMessenger;

packages/video_player/video_player/ios/Classes/messages.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Autogenerated from Pigeon (v0.1.0-experimental.10), do not edit directly.
1+
// Autogenerated from Pigeon (v0.1.0-experimental.11), do not edit directly.
22
// See also: https://pub.dev/packages/pigeon
33
#import "messages.h"
44
#import <Flutter/Flutter.h>

packages/video_player/video_player/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Flutter plugin for displaying inline video with other Flutter
44
# 0.10.y+z is compatible with 1.0.0, if you land a breaking change bump
55
# the version to 2.0.0.
66
# See more details: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0
7-
version: 0.10.10
7+
version: 0.10.11
88
homepage: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player
99

1010
flutter:
@@ -35,7 +35,7 @@ dev_dependencies:
3535
flutter_test:
3636
sdk: flutter
3737
pedantic: ^1.8.0
38-
pigeon: 0.1.0-experimental.10
38+
pigeon: 0.1.0-experimental.11
3939

4040
environment:
4141
sdk: ">=2.1.0 <3.0.0"

0 commit comments

Comments
 (0)