当前位置:网站首页>一个方案提升Flutter内存利用率
一个方案提升Flutter内存利用率
2020-11-08 10:29:00 【InfoQ】
背景
我们闲鱼使用的图片方案是自研的外接纹理方案:
- Android侧创建SurfaceTexture,通过FlutterJNI注册到Flutter engine里,最后返回texture id给Flutter应用层,应用层使用Texture Widget和textue id去显示图片纹理。
- 纹理数据则是在Android侧,通过OpenGL将图片纹理写入到SurfaceTexture,然后通过Flutter engine里的共享内存,将纹理数据传入到应用层,最终交给Skia渲染。
这里面存在的问题: Flutter应用层的纹理数据没有缓存,每次都需要重新将Bitmap数据渲染成纹理,再交给Flutter应用层使用。Native图片加载会内存缓存,Flutter自身提供的图片库也存在缓存,这2个缓存相互隔离,占用很大的内存空间。而且Flutter图片缓存基本都是存放的本地资源图,而我们Flutter页面上大部分其实都是网络下载的外接纹理图片,导致缓存资源利用率很低。
分析
针对上述的3个问题,我们先抛开技术实现,假设下要解决这3个问题,最理想的一个解决方案是什么:
- 纹理没有缓存,那我们在应用层增加一个纹理的内存缓存就解决了。
- 当上层的应用层已经缓存纹理,那Native侧的Bitmap的内存缓存也可以被去掉,只保留图片资源的磁盘缓存。
- 整个App的内存缓存,只有纹理缓存,Flutter的ImageCache缓存,为了避免内存资源的浪费,将这2个缓存合成一个
原文链接:【https://www.infoq.cn/article/4t9HrwJFvRh41X2328Gy】。未经作者许可,禁止转载。
版权声明
本文为[InfoQ]所创,转载请带上原文链接,感谢
https://www.infoq.cn/article/4t9HrwJFvRh41X2328Gy?utm_source=rss&utm_medium=article
边栏推荐
- 年轻一代 winner 的程序人生,改变世界的起点藏在身边
- C++在C的基础上改进了哪些细节
- 2天,利用下班后的4小时开发一个测试工具
- Px4 adds new applications
- python学习 day1——基础学习
- 进程、线程和协程的区别
- 数据科学面试应关注的6个要点
- Bili Bili common API
- vivoy73s和荣耀30青春版的区别
- Game mathematical derivation AC code (high precision and low precision multiplication and division comparison) + 60 code (long long) + 20 point code (Full Permutation + deep search DFS)
猜你喜欢
vivoS7e和vivoS7的区别 哪个更值得入手
5g/4g工业无线路由器
More than 50 object detection datasets from different industries
PCR and PTS calculation and inverse operation in TS stream
Deeplight Technology Bluetooth protocol SRRC certification services
What is the difference between vivoy73s and vivoy70s
SQL Server 2008R2 18456 error resolution
软件测试培训班出来好找工作么
[original] about the abnormal situation of high version poi autosizecolumn method
解决Safari浏览器下载文件文件名称乱码的问题
随机推荐
The difference between vivoy 73s and glory 30 Youth Edition
ASP.NET A complete solution based on exception handling in MVC
C++在C的基础上改进了哪些细节
攻防世界之web新手题
Improvement of rate limit for laravel8 update
laravel8更新之速率限制改进
M-end software product design considerations - Zhihu
维图PDMS切图软件
Fgagt: flow guided adaptive graph tracking
What is the difference between vivoy73s and vivoy70s
数据科学面试应关注的6个要点
Spotify是如何推动数据驱动决策的?
模板链表类学习
Face recognition: attack types and anti spoofing techniques
盘点那些你没想到的云计算应用场景(上)
Is software testing training class easy to find a job
双向LSTM在时间序列异常值检测的应用
Function periodic table filter value selectedvalue
Visual studio 2015 unresponsive / stopped working problem resolution
洞察——风格注意力网络(SANet)在任意风格迁移中的应用