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

Conversation

@gaaclarke
Copy link
Member

@gaaclarke gaaclarke commented Feb 20, 2020

Description

Upgraded to use pigeon, parent commit: #2617

Related Issues

Related: flutter/flutter#32930

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

@gaaclarke gaaclarke force-pushed the video-player-pigeon branch 4 times, most recently from 8c4c695 to 0f60ba4 Compare February 21, 2020 18:47
@gaaclarke gaaclarke force-pushed the video-player-pigeon branch 2 times, most recently from 0a689b7 to e728df8 Compare March 17, 2020 21:29
Copy link
Member

@xster xster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some notes but this is looking great!!

public class Messages {

/** Generated class from Pigeon that represents data sent in messages. */
public static class VoidMessage {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya, supporting null would be great

}

/** Generated class from Pigeon that represents data sent in messages. */
public static class TextureMessage {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more of a comment for https://github.com/flutter/plugins/pull/2544/files#diff-eba6bc6c27f777f5309e5a219983ec11R34 but I'm here now. This seems like a good place to demonstrate "primitives" since the original implementation for java is just a long too. Could the IDL just be int create(CreateMessage msg);?

public Long getTextureId() { return textureId; }
public void setTextureId(Long setterArg) { this.textureId = setterArg; }

HashMap toMap() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meta-context for the comment above, one of the struggles big apps tend to get into is once you unpack the APK, 1/3 of the APK size is from the proto generated outputs with a bunch of helper functions. I don't think we'll run into it any time soon but it's good to let primitives be primitives where possible.

public static class CreateMessage {
private String asset;
public String getAsset() { return asset; }
public void setAsset(String setterArg) { this.asset = setterArg; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the java part wasn't in the original doc but looking at this again, could we default to immutables only (fields can only be set via constructor (fromMap in this case) unless specifically annotated?

public String getFormatHint() { return formatHint; }
public void setFormatHint(String setterArg) { this.formatHint = setterArg; }

HashMap toMap() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking, since the APIs are directional in the IDL, this should theoretically never be needed right? Could we omit this by default unless we annotate it somehow?

VoidMessage pause(TextureMessage msg);
}

void setupPigeon(PigeonOptions opts) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in this whole file, only the import line and this function are required, everything else is freeform right? I wish we can somehow make this distinction clearer. Maybe we need a pub run to generate the dart template and this is pre-filled with a big dartdoc saying you need to fill this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function isn't required. All of these flags can be supplied at command-line. I added this function so people can save arguments.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, understood.

1- I just meant how can we provide a clearer affordance to this thing? Maybe just a doc in the readme is ok. But since we're telling people to create this file from scratch, it would be good to have some template available.

2- kinda unrelated, can we tweak the name to not have setup in there? The generated java/objc code has the word setup in the static functions too and they mean pretty different things than this setup. Could be confusing if people cognitively mixed those things. Maybe just configurePigeon or some such.

video_player_platform_interface: ^1.0.1
video_player_platform_interface:
path: ../video_player_platform_interface
# The design on https://flutter.dev/go/federated-plugins was to leave
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your change invalidates this comment right?

sdk: flutter
pedantic: ^1.8.0
pigeon:
path: ../../../../packages/packages/pigeon
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably just reference a version here right? If we were to actually check it in.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change that when i switch from being a draft.

} else {
return VoidMessage._fromMap(replyMap['result']);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: some whitespace unbalance here

class VideoPlayerApi {
Future<VoidMessage> initialize(VoidMessage arg) async {
Map requestMap = arg._toMap();
BasicMessageChannel channel =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this part is a bit different from the receiving side. I get the ergonomics of it but I wonder what's the cost (if a function is invoked on each frame). Is it reasonable to save it somewhere?

@gaaclarke
Copy link
Member Author

@xster the Android and iOS example apps both work now, yay.

@gaaclarke gaaclarke force-pushed the video-player-pigeon branch 2 times, most recently from fc5eddf to d79ff02 Compare March 23, 2020 22:11
@gaaclarke gaaclarke force-pushed the video-player-pigeon branch 4 times, most recently from 99e6b0b to ed4b42b Compare April 28, 2020 22:01
Copy link
Member

@xster xster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

return asset;
}

public void setAsset(String setterArg) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgot if we talked about this before. Perhaps for a v1.1. Can't all these be construction arguments rather than setters? Since the "receiver" can theoretically take this object as is and just pass it around deeper into their application as immutable data. It's harder to do if it's mutable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea I've considered it i n the past, just haven't had the time: flutter/flutter#56496

Since java doesn't have named parameters i've never prioritized it to keep the generated code similar across platforms.

@@ -0,0 +1,50 @@
import 'package:pigeon/pigeon_lib.dart';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, the convention is to have the main dart file be the same name as the package, e.g. package:pigeon/pigeon.dart

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FLTVideoPlayerPlugin* instance = [[FLTVideoPlayerPlugin alloc] initWithRegistrar:registrar];
[registrar addMethodCallDelegate:instance channel:channel];
[registrar publish:instance];
FLTVideoPlayerApiSetup(registrar.messenger, instance);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can make the requirement of calling this function more explicit.
What is the current failure message if the user didn't call this before using the pigeon generated code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the same error then if someone sent a message to a channel that hasn't had a callback set for it. It doesn't say anything specifically about Pigeon. Thats good feedback. I'll look into that for future versions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I guess documentations on the method would also help in some patch release.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+ (FLTTextureMessage *)fromMap:(NSDictionary *)dict {
FLTTextureMessage *result = [[FLTTextureMessage alloc] init];
result.textureId = dict[@"textureId"];
if ((NSNull *)result.textureId == [NSNull null]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits:
use if (![result.textureId iSKindOfClass:[NSNumber class]])
would also check the the type.
Or if we want to be more explicit about plugin passing the wrong type, we can add

if (![result.textureId iSKindOfClass:[NSNumber class]]) {
    throw...
}

}
- (NSDictionary *)toMap {
return
[NSDictionary dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits: I personally prefer

@{
  @"textureId" : self.textureId ? self.textureId : [NSNull null])
};

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I would update this but since it is part of the generated code it is really an issue with pigeon, not this PR. That requires republishing pigeon, since it's a nit I'll address it later if you don't mind.

description: Flutter plugin for displaying inline video with other Flutter
widgets on Android and iOS.
version: 0.10.9+1
version: 0.10.10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this PR change the public api of the plugin?
We usually only update minors when there are non-breaking public api changes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't change the API. It isn't a breaking change in that sense. It adds no new functionality from the users perspective.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it doesn't add anything from users perspective, we should change it to 0.10.9+2 so users
who depends on video_player: ^0.10.9^ can get this update.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that the "+N" nomenclature is for changes that don't change the binary. This doesn't change the intention of the code, but the binary is definitely changed.

Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gaaclarke gaaclarke force-pushed the video-player-pigeon branch from dab2092 to d431937 Compare May 8, 2020 05:37
@gaaclarke
Copy link
Member Author

Landing on red, the only breaking CI is submit-queue, this should fix it. @cyanglaz I had to make a few changes after your LGTM, but they were all fixing tests in case you want to review them.

@gaaclarke gaaclarke merged commit c65bdd0 into flutter:master May 8, 2020
stuartmorgan-g pushed a commit to stuartmorgan-g/plugins that referenced this pull request May 11, 2020
mgonzalezc pushed a commit to mgonzalezc/plugins that referenced this pull request May 19, 2020
* master: (96 commits)
  Update README.md (flutter#2768)
  [url_launcher_web] Launch mailto urls in same window in Safari (flutter#2740)
  update README with enableJavaScript info (flutter#2766)
  Run publish ci check on master (flutter#2764)
  [image_picker] Add documentation for Android external storage permissions (flutter#2765)
  [package_info] add support for macos to package_info plugin (flutter#2618)
  fixed detach from engine logic (flutter#2759)
  [url_launcher] Initialize previousAutomaticSystemUiAdjustment in launch (flutter#2757)
  [google_maps_flutter] add todo on skipped test. (flutter#2752)
  [google_maps_flutter] use `WaitUntilTouchesEndedPolicy` to fix the cameraIdle not called issue on iOS (flutter#2746)
  Use Xvfb for Linux desktop tests (flutter#2750)
  update lower dart bound to 2.1.0 (flutter#2751)
  [camera] Update lower bound of dart dependency to 2.1.0. (flutter#2749)
  [battery] update dart deps lower bound to 2.1.0 (flutter#2748)
  [android_alarm_manager] update dart deps lower bound to 2.1.0 (flutter#2747)
  [url_launcher] Add web to example app. (flutter#2736)
  [in_app_purchase] update docs to warn about `completePurchase` (flutter#2739)
  [video_player] upgraded video_player to use pigeon (flutter#2544)
  [video_player]: fixed platform_interface unit tests (flutter#2745)
  [video_player]: added test class to fix video_player unit tests (flutter#2744)
  ...

# Conflicts:
#	packages/quick_actions/ios/Classes/FLTQuickActionsPlugin.m
EdwinRomelta pushed a commit to EdwinRomelta/plugins that referenced this pull request Jun 11, 2020
jorgefspereira pushed a commit to jorgefspereira/plugins_flutter that referenced this pull request Oct 10, 2020
FlutterSu pushed a commit to FlutterSu/flutter-plugins that referenced this pull request Nov 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants