Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
小程序终端技术架构
Search
yiminghe
March 30, 2019
Programming
290
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
小程序终端技术架构
yiminghe
March 30, 2019
More Decks by yiminghe
See All by yiminghe
支付宝小程序的开放架构
yiminghe
0
220
gitc2016 react based architecture
yiminghe
1
190
antd at qcon2016
yiminghe
1
250
react-based architecture
yiminghe
2
190
React Ecosystem At Ant Financial
yiminghe
4
2.3k
ant design preview
yiminghe
1
340
react best practice
yiminghe
3
230
react at alipay
yiminghe
43
4.6k
form validation in react
yiminghe
4
580
Other Decks in Programming
See All in Programming
地域 SRE コミュニティ最前線 - ホンマでっかSRE勉強会
tk3fftk
0
270
Apache Hive: そしてCloud Native Lakehouseへ
okumin
1
160
霧の中の代数的エフェクト
funnyycat
1
420
SLOをサービス品質の共通言語にするために 取り組んできたこと
wakana0222
0
540
Laravelで学ぶ Webアプリケーションチューニング入門/web_application_tuning_101
hanhan1978
4
1.3k
共通化で考えるべきは、実装より公開する型だった
codeegg
0
270
エンジニアにデザインハーネスを 〜デザインプロセスを規定するためのハーネス〜 / Design harness from an engineer's perspective
rkaga
2
1.6k
ビデオ通話が繋がる0.2秒で何が起きているのか
supurazako
2
150
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
540
Android CLI
fornewid
0
120
えっ!!コードを読まずに開発を!?
hananouchi
0
230
任せる範囲はこう広がった / How the Scope of AI Delegation Has Expanded
nrslib
1
270
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.5k
Everyday Curiosity
cassininazir
0
260
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
310
Facilitating Awesome Meetings
lara
57
7k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
330
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
How to make the Groovebox
asonas
2
2.3k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
A Tale of Four Properties
chriscoyier
163
24k
Between Models and Reality
mayunak
4
380
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
350
Transcript
小程序终端技术架构 何一鸣/承玉
INTRODUCTION 2010 年加入阿里,先后负责 KISSY/ant-design/ant- design-mobile 等基础类库的架构和核心研发工作, 自 2016 起开始进行小程序相关工作,负责小程序前端
架构以及框架核心开发。 Github/Twitter/Gmail: yiminghe
&217(176 架构 性能优化 后续发展
JSCore 保活 机制 离线包 形式 精简 运行环境 扩展性
引入JSCore:小程序会创 建一个JSCore ,专门负 责逻辑处理,绑定所有页 面,页面只负责渲染,尽 可能提升每个页面的渲染 性能。 引入保活机制:当离开当 前小程序时,小程序会在 后台继续运行5分钟,再 次点击直接秒开。 小程序框架以离线包形式 在整个客户端层面统一管 理和更新,并且框架代码 会被UC内核统一缓存为 字节码,所有小程序业务 公用,减少业务包大小。 基础组件,统一api调用 方式,对于纯H5性能较 差的部分提供native实现 以提升性能(map、 input)。 npm第三方模块,自定义 组件,web-view。 3 5 体验差异小 4 5 6 7 小程序整体效果好,H5对开发者要求 高,产出结果体验差异较大 webview 渲染优化 同容器/内核结合优化框架渲染。 1 2
DSL (acss/axml/js) Mini-App bundle 编译构建 Mini-App container 离线包下载执行 framework
webview jscore video canvas …
Components Framework Native SDK React WEBVIEW IDE DSL(template/css/js) js
bundle build run
JS Template CSS App Page Component
App({ onLaunch() {}, onShow() {}, }) Page({ onLoad() {},
onUnload() {}, }) view {color: red} <view><C /></view> Component({ didMount() {}, didUnmount() {}, }) <view><C2 /></view> .c {color: green}
onInit deriveDataFromProps
JSCore Native App java/ios Page A webview Preloaded
webview JSON bridge JSON bridge framework worker.bundle framework render.bundle framework render.bundle
JSCore webview Page a js Page a css/template Page
b js webview Page b css/template native render data ui event render data ui event api system event
page data/component data 为 json 格式 Ø 不能有复杂对象,例如 new Date()
Ø 不能有循环引用,直接传输出错 Ø 不要直接修改 this.data, 使用 setData/$spliceData 异步渲染/事件 Ø setData:使用回调函数依赖渲染结果, setData(data, callback) Ø 只能静态阻止冒泡:catchTap
Native JSCore webview launch onLaunch page onLoad->onShow User Event
render onReady handler re-render send data navigateTo onHide onShow webview init data
&217(176 架构 性能优化 后续发展
0 50 100 150 200 250 300 350 50
90 130 170 210 250 290 330 370 410 小程序中渲染耗时随DOM节点数的变化曲线 小程序中渲染耗时随DOM节点数的变化曲线
0 50 100 150 200 250 300 1kB 2kB
25kB 50kB 75kB 150kB 300kB 500kB 1000kB 2000kB 数据传输耗时 (ms) 数据传输耗时 (ms)
$spliceData 指定路径修改数据 避免频繁调用 setData 控制 dataset 大小
避免过度调用同步 API AXML 中 for 指定 key
背景 包大小限制为 3M 不满足复杂应用。 包大小过大,网络不佳场景下,小程序首页启动慢。 完整包下载 主包下载 解压 校验
渲染 解压 校验 渲染 剩余包下载 解压 校验 首屏显示 现状: 4月:
背景 首屏 loading 时间长。 启发自 server-side render。 首次打开 执行
JS save html 再次打开
&217(176 架构 性能优化 后续发展
分包加载 snapshot 插件组件 component2 AI 云开放 API …
支付宝小程序 阿里小程序 AI
None