Flutter iOS动画在第一次运行时就很不稳定 [英] Flutter iOS animations are janky on first run

查看:74
本文介绍了Flutter iOS动画在第一次运行时就很不稳定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从Flutter 1.12开始(当Flutter从OpenGL切换到Metal渲染时),应用程序的首次运行似乎变得很讨厌(更频繁地跳过帧).

Since Flutter 1.12 (when Flutter switched to Metal rendering from OpenGL), first runs of an application appear to jank (skip frames more often).

Flutter团队正在正在为此工作,但与此同时我该怎么办?会吗?

The Flutter team is working on this, but in the mean time what can I do?

推荐答案

在进行任何操作之前:请确保您看到的垃圾确实与此问题相关.如果您的应用程序已经在iOS的OpenGL后端上变得混乱,或者在Android上(实现了着色器缓存)变得混乱,那么您可能会遇到其他与性能相关的问题.尝试通过在Flutter中进行性能分析-即记录一些时间表并分析发生的情况框架中的工作负载.

Before anything: make sure the jank you are seeing is truly related to this issue. If your application was already janky on the OpenGL backend in iOS, or is janky on Android (where shader caching is implemented), you likely have some other performance related problem. Try working through performance profiling in Flutter - i.e. record some timelines and analyze what's going on in frame workloads.

编辑2/23/2021

金属二进制存档工作被证明是死胡同.有关更多详细信息,请参见 https://github.com/flutter/engine/pull/23914 .对于Flutter团队来说,这仍然是高度优先的项目,但是修复的时间表目前尚不清楚.

Metal binary archive work turned out to be a dead end. See https://github.com/flutter/engine/pull/23914 for more details. This is still a high priority item for the Flutter team, but the timeline for a fix is unknown right now.

结束编辑

否则:

  • 查看是否可以使用更简单的着色器.例如,避免进行Alpha混合,避免进行梯度计算,避免使用昂贵的片段等.
  • 降级至Flutter 1.12.
    • 这可能需要挑选其他所需的修补程序.
    • 这可能需要降级某些程序包,或向后移植那些不适用于1.12的程序包.
    • 请参见说明此处.
    • 这几乎肯定会为某些应用程序和/或引入回归设备.这些可能对您而言可能是可接受的,也可能是您不可接受的.Flutter团队不再支持iOS上的OpenGL,并且由于无法修复而将要求对其进行错误修复的请求也将关闭.
    • See instructions here.
    • This will almost definitely introduce regressions for some applications and/or devices. These may or may not be acceptable for you. OpenGL on iOS is no longer supported by the Flutter team, and requests for bug fixes on it will be closed as won't fix.

    一些背景:

    着色器是Skia从各种绘制命令创建的小程序,用于创建GPU可以执行以在屏幕上实际绘制像素的程序.编译它们可能花费很短的时间,并且不同的场景可能需要不同的着色器程序.Flutter的体系结构旨在缓存和重用已编译的着色器程序,以便在编译后即可重用它们.在Skia中基于OpenGL的后端中已经存在对此的支持,但是对于基于Metal的后端仍在工作中(请参见 https://skbug.com/10804 ).

    Shaders are small programs that Skia creates from various drawing commands to create a program that the GPU can execute to actually draw pixels on the screen. Compiling them can take non-trivial amounts of time, and different scenes may require different shader programs. Flutter's architecture is designed to cache and reuse compiled shader programs so that they can be reused once they are compiled. Support for this exists in the OpenGL based backend in Skia, but is still being worked on for the Metal based backend (see https://skbug.com/10804).

    有很多充分的理由迁移到金属.

    There were a lot of good reasons to migrate to Metal.

    • Apple将弃用OpenGL
    • 在OpenGL后端中观察到与内存和帧速率有关的问题,这些问题很快就变成了死胡同.由于弃用,Apple的性能分析和调试工具现在都面向Metal.观察到转移到Metal可以解决许多问题.
    • 人们相信可以实现对Metal的核心支持.这包括基本渲染,跨上下文图像和平台视图支持.不幸的是,这不包括对着色器缓存的支持.
    • Apple is deprecating OpenGL
    • Memory and frame rate related issues were observed in the OpenGL backend that were rapidly becoming dead ends. Apple's profiling and debugging tooling is all geared towards Metal now due to deprecation. Many issues were observed to be completely resolved by shifting to Metal.
    • Core support for Metal was believed to be achieved. This included basic rendering, cross context images, and platform view support. This did not include support for shader caching, unfortunately.

    我们曾简要考虑过同时支持OpenGL和Metal ,但决定不支持.解决堆栈中该层中的错误的资源有限,我们已经知道Metal解决了许多与性能相关的问题.

    We did briefly consider supporting both OpenGL and Metal, but decided not to. There are limited resources to address bugs in that layer of the stack, we were already aware of a number of perofrmance related issues that Metal solved.

    这篇关于Flutter iOS动画在第一次运行时就很不稳定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆