Commit 7063d75
authored
[video_player_avfoundation] removes unnecessary duration and size check before sending the initialized event (#9534)
Fixes flutter/flutter#166914. The duration check was first introduced [here](flutter/plugins#1554) but zero division should probably be handled by the client not the plugin.
Also I suspect that flutter/flutter#91975 wasn't caused by an AVFoundation bug but rather a bug in `video_player_avfoundation`:
The `_isInitialized` flag was roughly equivalent to `.readyToPlay` [a long time ago](https://github.com/flutter/plugins/pull/280/files#diff-f4c7ef029bb5e0be8a6851b6b022c745dc4e99e3739f1c2f7f4944b85bc154a6R174-R178). The flag was later re-purposed to indicate whether an `initialized` message has already been sent (to make sure the message is only sent once), and [that PR](flutter/plugins#1552) also introduced a size check to determine whether the media is loaded (which doesn't seem to be correct, `.readyToPlay` is the public API for this, see Apple's [AVPlayerDemo](https://developer.apple.com/library/archive/samplecode/AVPlayerDemo/Listings/Classes_AVPlayerDemoPlaybackViewController_m.html#//apple_ref/doc/uid/DTS40010101-Classes_AVPlayerDemoPlaybackViewController_m-DontLinkElementID_8)). But that PR didn't update the `onListenWithArguments` implementation so the plugin started sending `initialized` events on first subscription even the `AVPlayerItem` isn't ready to play. So that looks like a bug in the plugin not in AVFoundation and that allows us to remove a bunch of workarounds.
Couldn't reproduce flutter/flutter#91975 on iOS16 with this patch (I can't install iOS15 sim runtime, it fails silently, but on iOS16 it still hits the size + duration check callpath so I think not much has changed from iOS15 to iOS16 as far as AVFoundation stuff is concerned).
I didn't try to reproduce flutter/flutter#19197 with this patch since the issue doesn't have a minimal repro. I did not change the `_isInitialized` semantic so I assume the patch won't regress that fix.
More on `isInitialized`:
The player implementation doesn't have to rely on this property, if `AVPlayerItem.Status` can not recover from `.failed` to `.readyToPlay` (i.e. it can only change to `.readyToPlay` once). But the documentation doesn't say if that is the case.
## Pre-Review Checklist
[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.1 parent 71e05e1 commit 7063d75
File tree
11 files changed
+206
-143
lines changed- packages/video_player
- video_player_android/example/lib
- video_player_avfoundation
- darwin
- RunnerTests
- video_player_avfoundation/Sources/video_player_avfoundation
- include/video_player_avfoundation
- example/lib
- video_player
- lib
- test
11 files changed
+206
-143
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| |||
Lines changed: 37 additions & 47 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
82 | | - | |
| 83 | + | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
| |||
430 | 431 | | |
431 | 432 | | |
432 | 433 | | |
433 | | - | |
| 434 | + | |
434 | 435 | | |
435 | 436 | | |
436 | 437 | | |
| |||
863 | 864 | | |
864 | 865 | | |
865 | 866 | | |
866 | | - | |
867 | | - | |
868 | | - | |
869 | | - | |
870 | | - | |
871 | | - | |
872 | | - | |
873 | | - | |
874 | | - | |
875 | | - | |
876 | | - | |
877 | | - | |
878 | | - | |
879 | 867 | | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
880 | 876 | | |
881 | 877 | | |
882 | 878 | | |
883 | 879 | | |
884 | 880 | | |
885 | 881 | | |
886 | 882 | | |
887 | | - | |
| 883 | + | |
888 | 884 | | |
889 | 885 | | |
890 | 886 | | |
891 | 887 | | |
892 | 888 | | |
893 | | - | |
| 889 | + | |
894 | 890 | | |
895 | | - | |
| 891 | + | |
896 | 892 | | |
897 | 893 | | |
898 | 894 | | |
899 | | - | |
900 | | - | |
901 | | - | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
902 | 898 | | |
903 | 899 | | |
904 | 900 | | |
| |||
1089 | 1085 | | |
1090 | 1086 | | |
1091 | 1087 | | |
1092 | | - | |
1093 | | - | |
1094 | | - | |
1095 | | - | |
1096 | | - | |
1097 | | - | |
1098 | | - | |
1099 | | - | |
1100 | | - | |
1101 | | - | |
1102 | | - | |
1103 | 1088 | | |
1104 | 1089 | | |
1105 | 1090 | | |
1106 | 1091 | | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
1107 | 1098 | | |
1108 | 1099 | | |
1109 | 1100 | | |
1110 | | - | |
| 1101 | + | |
1111 | 1102 | | |
1112 | 1103 | | |
1113 | 1104 | | |
1114 | | - | |
1115 | | - | |
1116 | | - | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
1117 | 1108 | | |
1118 | 1109 | | |
1119 | 1110 | | |
1120 | 1111 | | |
1121 | | - | |
| 1112 | + | |
1122 | 1113 | | |
1123 | 1114 | | |
1124 | 1115 | | |
1125 | 1116 | | |
1126 | | - | |
1127 | | - | |
1128 | | - | |
1129 | | - | |
1130 | | - | |
1131 | | - | |
1132 | | - | |
1133 | | - | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
1134 | 1124 | | |
1135 | 1125 | | |
1136 | 1126 | | |
1137 | 1127 | | |
1138 | | - | |
| 1128 | + | |
1139 | 1129 | | |
1140 | 1130 | | |
1141 | 1131 | | |
1142 | 1132 | | |
1143 | | - | |
| 1133 | + | |
1144 | 1134 | | |
1145 | 1135 | | |
1146 | 1136 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
Lines changed: 81 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
175 | 256 | | |
176 | 257 | | |
177 | 258 | | |
| |||
Lines changed: 14 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
433 | 434 | | |
434 | 435 | | |
435 | 436 | | |
436 | | - | |
437 | | - | |
| 437 | + | |
438 | 438 | | |
| 439 | + | |
439 | 440 | | |
440 | 441 | | |
441 | 442 | | |
| |||
535 | 536 | | |
536 | 537 | | |
537 | 538 | | |
538 | | - | |
| 539 | + | |
539 | 540 | | |
540 | | - | |
| 541 | + | |
541 | 542 | | |
542 | 543 | | |
543 | 544 | | |
| |||
546 | 547 | | |
547 | 548 | | |
548 | 549 | | |
549 | | - | |
| 550 | + | |
550 | 551 | | |
551 | 552 | | |
552 | 553 | | |
553 | 554 | | |
554 | | - | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
561 | 561 | | |
562 | 562 | | |
563 | 563 | | |
564 | 564 | | |
565 | 565 | | |
566 | | - | |
| 566 | + | |
567 | 567 | | |
568 | 568 | | |
569 | 569 | | |
570 | 570 | | |
571 | | - | |
| 571 | + | |
572 | 572 | | |
573 | 573 | | |
574 | 574 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
1 | 7 | | |
2 | 8 | | |
3 | 9 | | |
| |||
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
936 | 936 | | |
937 | 937 | | |
938 | 938 | | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
939 | 966 | | |
940 | 967 | | |
941 | 968 | | |
| |||
0 commit comments