Repository navigation
feat(ios): 支持画中画播放 - #2646
feat(ios): 支持画中画播放#2646sibogentleman wants to merge 9 commits into
Conversation
| setState(() {}); | ||
| if (!active && !restored && !backgroundPlayback && | ||
| WidgetsBinding.instance.lifecycleState == AppLifecycleState.paused) { | ||
| unawaited(playerController.pause(enableSync: false)); |
There was a problem hiding this comment.
SUGGESTION: The deferred background pause does not suspend prefetch
While _iosPip.keepPlaybackInBackground is true, the paused branch of didChangeAppLifecycleState is skipped, and that branch is what calls playback.setPrefetchSuspended(true) ("pause alone keeps prefetching"). This line, and the matching failed-entry path at line 336, are the deferred version of that branch, but they only call pause. So when PiP is closed, or entry fails, while the app is backgrounded with background playback disabled, prefetch keeps running until the next resumed event. Consider calling setPrefetchSuspended(true) here as well, or reusing the paused-branch logic.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
There was a problem hiding this comment.
To use Kilo from GitHub you first need to link your GitHub account to Kilo. Link your Kilo account to continue. After linking, mention me again in this issue or pull request.
There was a problem hiding this comment.
To use Kilo from GitHub you first need to link your GitHub account to Kilo. Link your Kilo account to continue. After linking, mention me again in this issue or pull request.
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (14 files)
Incremental review (
Previous findings, checked against the current HEAD: the Assumptions / gaps: The media-kit fork sources are not available locally, so I could not verify:
Per the author's notes, the Swift XCTest cases compile but have still not been run. Fix these issues in Kilo Cloud Previous Review Summaries (5 snapshots, latest commit a7a0f33)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit a7a0f33)Status: No Issues Found | Recommendation: Merge Files Reviewed (1 file)
Incremental review: Since Previous findings, checked against the current HEAD:
The native XCTest cases still haven't run, per the author's own note, so the Swift PiP adapter has no runtime test results yet. Previous review (commit a57547a)Status: No Issues Found | Recommendation: Merge Files Reviewed (5 files)
Incremental review: Since
The callers in The existing I couldn't compile any of this here. Without Flutter's iOS headers in the sandbox, I couldn't confirm that every forwarded Previous review (commit cde6091)Status: No Issues Found | Recommendation: Merge Files Reviewed (1 file)
Incremental review: Since Previous review (commit ae33a6f)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (1 file)
Incremental review: The only change since Fix these issues in Kilo Cloud Previous review (commit 1bc6aa0)Status: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (16 files)
Note: media-kit's native source is a git dependency and is not in the workspace. I could not confirm the assumption in Reviewed by claude-opus-5.5 · Input: 266 · Output: 9.1K · Cached: 637.8K |
Co-authored-by: kilo-code-bot[bot] <240665456+kilo-code-bot[bot]@users.noreply.github.com>
|
注意到此实现基于objc,为什么没有使用更新的swift并与项目的其他插件保持一致 |
|
手写了部分CVPixel使用的实现,objc 仅仅是个人偏好,会改用 swift 实现后再提交 |
|
@Predidit 可以看看最新的 swift 实现,已经在 ios 上本地测试过 |
|
@Predidit 看看可以合并不 |
|
我没有可以测试此功能的设备,需要等待其他贡献者审查 |
|
在其他贡献者审查前,有以下问题可以先处理
|
| git: | ||
| url: https://github.com/Predidit/media-kit.git | ||
| ref: 803c4a27912091db6f839d48d1b984a0d9f588c7 | ||
| url: https://github.com/sibogentleman/media-kit.git |
There was a problem hiding this comment.
WARNING: media_kit / media_kit_video now resolve from a personal fork
Both packages (lines 97 and 102, and the matching pubspec.lock entries) move from Predidit/media-kit@803c4a2 to sibogentleman/media-kit@cb118d7. Since 4fed48b removed the media_kit_libs_* overrides, these packages also supply the native libraries for every platform, not just iOS. Merging as-is means:
- a third-party repository controls code shipped on Android, Windows, macOS, Linux and OHOS;
- any fix that is in
803c4a2but missing fromcb118d7is silently lost (nothing in this repo showscb118d7descends from803c4a2); - future maintainer media-kit bumps cannot be applied until the dependency is switched back.
Consider merging Predidit/media-kit PR #41 first and pinning the resulting Predidit/media-kit commit here. Failing that, confirm that cb118d7 is rebased on 803c4a2 before merging.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
| renderer.setSoftwareRendering(handle: handle, enabled: software) { result in | ||
| if !software && result == .notReady { | ||
| self.waitingForRegistration.insert(handle) | ||
| retryGeneration = self.registrationGeneration |
There was a problem hiding this comment.
SUGGESTION: The retry generation is captured when the result arrives, not when the request is made
retryGeneration is read inside the setSoftwareRendering completion. Suppose the busy output's texture registers (and textureRegistered() runs) while that request is still pending. retryRegisteredOutputs() skips the handle, because it is in recreatingHandles and not yet in waitingForRegistration. .notReady then records the already-incremented generation, so the generation != registrationGeneration check in finish (line 183) never fires. The output stays on software rendering in the foreground until the next activation or texture registration.
This is reachable if media-kit completes asynchronously, which the comment at line 205 implies ("completes only once output work has drained"). Capturing let requestGeneration = self.registrationGeneration just before line 197, and assigning it here, would cover this case. It would still handle the case where registration happens after the result, which the existing test covers.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
|
看了下 media-kit 的封装还是不够理想,画中画本身的实现只是调用 ios 的 pip 能力,但是依然需要获取视频流,依赖的接口修改先提到你的 fork 分支上,可以先审阅看看,也许会有更好的接口封装方案 @Predidit P |
|
@Predidit 改动比较多,但是我觉得这个功能本身还是比较实用的,可以有空的时候给一些意见吗 |
|
我没有 mac ,这个功能需要其他维护者审查 |
Preserve the Darwin rendering API while incorporating the upstream Android libmpv 1.3.0 bundle update and Flutter 3.47.7 pin.
描述
为 iOS 15 以上的系统添加了小窗播放的功能,在 iOS 27 的 iPhone 16 Pro 上真机测试通过。
关联的 Issues
[feat]: iOS的小窗模式 #2588
PR 类型
AI 辅助开发
AI 辅助模型: OpenAI GPT-6(Astra)
本次实现及代码整理使用了 AI,由 Codex 复核代码、运行自动检查,提交者已进行真机手动测试。
提交前检查
附注
验证环境:Flutter 3.47.6 / Dart 3.13.5。
flutter test --no-pub:261 项通过,覆盖 PiP 通道、状态同步、视频轨道恢复、并发切换及页面销毁 / 会话交接。flutter analyze --no-pub --no-fatal-infos --fatal-warnings:通过,无错误或警告;17 条 info 均位于未修改文件。flutter build ios --release --no-codesign --no-pub:通过。runtime path not found错误阻塞,尚未取得运行结果。小窗期间使用同一个 mpv 播放器的软件视频输出,关闭后在前台恢复 GPU 输出;会增加 CPU / 内存带宽开销。Flutter 弹幕及字幕覆盖层不显示在小窗内,暂不自动进入小窗。使用说明和后续性能回归项目见
docs/ios-picture-in-picture.md。本轮审查修复:
utils中的AsyncSingleFlight/AsyncSerialQueue。cb118d7d078dd25fbbad3e67180eb5b6639f6044,无需本地路径覆盖;配套改动合入后可一起切回上游。setState。