的alpha<会明显感觉到卡 s进行监 tIntersectsRect
CGIm data-mark="6hu我们添加了,但是,如果连 从磁盘中加载到 放用到的那一部 的shouldRasteri的内存全部加载 接着我们观察 0x九):性能优化相an class="6hu-5 class="6hu-673ments 工):
(1)0 t 3 pt成NO(rect.sig" data-id="healass="6hu-63650磁盘读取数据到 d 0数之 ch_wait(lsl_sem顿的方式来监控 ass="hljs-comme,为了快速处理 S 性能优化相关 attachment wp-aypl" data-mark=s="6hu-79520-my6hu-59122-mypl"-mypl" data-mar"hljs-type">BOO>? D 9 s i尺a K } "hljs-type">CFAteImage(pan>age faultwhilepan>个问题,我< data-mark="6hu>,无背景色,透="IOS面试考察( 4 t 0 Ch620-mypl" data-同风格的cell可 CFAbso/span>te 函数的压缩呢?是否可 片很宝贵,CPK 4 -le="IOS面试考察也没释放过A导致GPU 相关优化: 由于使用了
点评移动网络优 示,而、静态分析al">true要将我们APP启动P极致体验之路tabs="6hu-74087-myclass="6hu-3162 copyable"> timeOut化的layerquote>
抖音 ypl" data-mark=">s 模板3============而是先根据内容 离屏渲染的可能 mark="6hu">k s u-69384-mypl" dpe">QuartzCore<>
6-mypl" data-ma V实地址>
W # ` PPage Faul.green
} . 7 ] Z n p` : xusn>ndsc如果在APP启动过 H &就能P % X q I件,既 App入到kCFRunLoopBs="6hu-57624-mydbf2a0.png">{ 1 4 $D / 9 5i M"heading" data- = v 6 y LCGContextRef>。但是在iOS 系项目中没用到的 chment wp-att-1据通过数据总卡s z lass="6hu-1904--12042-mypl" da1.2.4.5 LeaS m a t就卡死然后崩溃 15-mypl" data-mha info.js-keyword">leti>
听云 - ng" rel="attach图层遮挡的像素 a X + <">4 0 i Q p H Gdata-mark="6hu"2020/04/1587337/p>
juejin.i data-mark="6hu">1.1.else对象 image$ ^ 2 & = class="hljs-nuspan>BLE_STARTIlDisplayCell: fode>optional
i>
( A o F Mian> ="6hu">, * P u 因此我们二进制 nnone size-full> 。
内 到一起 ( 比如 ta-mark="6hu">(0-mypl" data-ma:性能优化相关 ="6hu-40932-myp* x f * a.commonModAppPerformancn> a I Gata-mark="6hu">fahoutAlpha;hu">^ $ ` M K > * __nullable ">u W E + 3 ,static示系统通示视图 方法从磁盘中加an class="hljs-gate类中hu-14445-mypl" n> {
CGImageRefd 件将采用不同的 必然会保持kCFRumaintrue<* C 1 提achment wp-att--5733-mypl" datu-60550-mypl" d利用UIBez="6hu-67320-myp者很好的了解每 的代理方法,ifspan>pPerformanhljs-type">CGIm
WWDC及内容
当我们创span> newImage k="6hu">a 1 +比CPU高 span>否则只能看="6hu-1152-mypl="6hu-70077-myp固定、不透明的 ghtbit九):性能优化相ta-mark="6hu">}少帧之后才执行 ng" rel="attachpl" data-mark="tent/uploads/20, 注册重用标识关问题" alt="IO试考察(九):性 以及对象分配情 件n k 掉应用重新打开 对象,比如用不 些Bitmap重新生 ype">CGRect函数执行 ss="6hu-48951-m>很多页,每一页86.png">1.2.4.8 o = kCGBitmapBy-76464-mypl" daachment wp-att-一般使用 RGB 即暂培训出来的同 无到有加载到物 lass="alignnone采用了虚拟内存 会对图片进行 co环的时间,当这 /1587337068-d3c colorsping" data-id="hs-number">140 lsl_ltrue
laypl" data-mark=激发苹果的watchy d l &"6hu">W N o a ~/a>
<1.2.4.4 Core的代码上
(trueoreFoundationU会预先 N P M { 修饰的 an class="6hu-3直同步信号)信号设置圆角,如果 -90b4683b29afd0ode>contentMode实录
3的原因之前,先 data-mark="6hu"pan class="6hu->的相关属性,比l" data-mark="612-mypl" data-m6f0d421c195a9a./span>eRef)中调用 a ? kCGImageAlpgure>Z i 要绘制纹理图片 的知识,来判断 $ # E +如果不为 NULL 初探
Ahu"># ? lllypl" data-mark=mark="6hu">@ W l" data-mark="6e">UIApplicatio dog机制kill掉 9-mypl" data-map-content/uploa">% L |UIKitCoree N 9 z="hljs swift coe 属性默认为truigure>
通过双击n> d使处理常态下的卡 Time));
= [static>50.0 &asrc="https://wwaunchTime,阴影效果re>
引用虚拟="6hu">b 2 D b -keyword">let 信息数量。每秒 9nit3 T =privateSystem Trace>, width, heighypl" data-mark=6hu-840-mypl" dpDelega文件 ass="hljs-litermypl" data-markode>)。
<更改下imageView>I , Ubispan> ing" data-id="h" src="https://code> :位图的 会将整个的 0 和 1 代表 de>opaque] 6lass="hljs-typelass="6hu-63965val为2,是保证每秒输| 8 3 T _ #CGBitmapCont界面的渲染性
ark="6hu"># : /type">UIColor,否则就设为"APP启动时间 pan>,所以我么 l n 1ToB6hu-70868-mypl",图片解码,需 k="6hu">C a } fark="6hu">@ , !q v 8 !< ] m ,的a-mark="6hu">] 值给 UIImageVie存加载原理的讲 M u新最接设置fra高效率,采用了 4,每当lass="6hu-63000fpsColor:
: 使用透明vi = <78630-mypl" dat/figure>
iOS手 u">J . n b K -BunLoopMode(name:
移动 A余的绘制工作。 mageRef);
UIBeziypl" data-mark=定时器serk="6hu">, M ^ setup ass="hljs-type"算,渲染到App右边的跟踪堆栈 ^lf
规定范围内 , 也f W % tce 使用 s://www.6hu.cc/6hu-19850-mypl"ss="hljs-built_表,进行外部镜 ljs-keyword">stering:离屏渲染pan class="hljss-type">NSDicti class="hljs-nu下代码:
="6hu-74995-myp-mypl" data-mar-mark="6hu">m S20/04/158733707hu.cc/wp-contenime: 3.89 mil解决方案,
-[c栈
的很像Window都是一种压缩的<">I M j O s } wlass="6hu-30744$ p - =<
阴影效果路径 -1f0
控 >
Instrumenn>ializers :
li 4 U g X |& t 3 587337067-600c5eRecording.dyli果
UIImage每次执行消息循 azyload wp-imagjs-number">3当前v d ASTICS选 k = 406-Optmypl" data-mark" data-mark="6h显示泄露的对象.8710-mypl" data8-mypl" data-ma帧缓冲,可降低 执行后续的绘制 操作是否可以放 218" src="httpsa-mark="6hu">g I c { { k h, width: ) # 单的广告页作为 Blue
/code> 计算。本身是yable">t ) o= O Du">} v & ^ m *
按需加载c指针,消耗 )1501-mypl" data-marpan>tch_semapho069-a6550fa06a1eLogger 。由于CPU的时间色即可。而如果 >是CoreAnan class="hljs-wp-image-1873" span class="6huhu.cc/wp-conten-61830-mypl" da数,从而达e [屏幕绘制原理:< wp-att-1893">< class="6hu-892class="heading"-1874" title="I,不透明的就设 次计算(调整和绘15.png" rel="at解,我们了解了 S K ( } 7 Q
动端objc_1.2 卡顿优化理性使用-s/2020/04/15873 A oor_qark="6hu">6 g }道我们操作系统 ljs-type">UITabageAlphaInfodyli82-mypl" data-m31b4bdebug模式下是没li>
图片6.获取图片的坐标
.wn>-at graphics conte =
iOS Ap/ul>
d ) 70-mypl" data-m使用的详细信息,.
其实就nt wp-att-1878" Q Q t果mypl" data-markrk="6hu">H & M I T D j第一次安装启动 的实现进行修改 OS微信内存监控<试发现不同
) ; S kclass="6hu-5835mage 解 在内存可控的前 能优化相关问题""6hu">T : 2 T {l" data-mark="628024-mypl" dat6 ( b ) A y Y
imageView.laye class="6hu-266-mypl" data-marss="6hu-45675-mr.addClip()
dra可以使用光栅化 m U 4 h p 6 __CFRunL解决这rget:有许多红色区域,译
探i>
FPS监控 itmap做额外计算:性能优化相关 itTimeri面试考察(九): r = UIColor.whiented")
k="6hu">. j 3c X afe^40-mypl" data-m进制重排进行优 ( (ppor class="alignno>estimatedHeigh-content/upload以在客户端处理 a-mark="6hu">H Map
AppPeutablePointer1.09 e ! E 略等),只请求 生什么危害,作 -number">55.0e p 2 tdata-id="headinta-mark="6hu">*bols: 部V 3 S I [ // same as -mark="6hu">V v渲染服务将图片 ark="6hu">F L g题" alt="IOS面 " data-mark="6hn>);
});
}
#prae>滑动时,会不 word">let
High Perf> 来设置输出与 lass="6hu-24330到屏幕的过程: -mark="6hu">) }当前线程的调用 -number">02 J ss="6hu-11340-mding-36">1.3 耗 t j o 8 oappli
AppStartL渲染.
an>ation-AdvancRow里面 ="6hu-19800-myp70920-mypl" dat函数无论如何运 Z。
结 de ( imageNamed"hljs-type">App class="6hu-251主线程直接渲染 会阻塞主y为YES,系:
ss="hljs-stringlass="heading" s/2020/04/15873>ring) {
__bloc不适用的可以先 data-mark="6hu"
FBMemoryPr0">
<-number">0x10aa==============<以删除ApCPU
蘑 pan>协作,CPU计使用就会对结果有影响, 下面这些方式:<会高亮那些被缩 tent/uploads/20word">return在使用FPS监 n> 放到3 class="headin,因为GPU将不会an class="6hu-3! x。tick: 进行 Objc 的 l" data-mark="6a O - i 5 QCGConte>
实olor.rednk.timestamp -
lt;1)x9 i ~ S" data-id="headspan class="6huass="6hu-27330-data-mark="6hu"ss="6hu-10676-m class="6hu-582u"> h V ="https://www.6="6hu">D j * O i>
浅析移动查看步骤如下hu">h Q 5 4mapho"6hu-42902-mypl:性能优化相关 !消耗也性能优化相关问 ss="hljs-keywork="6hu">W G o Dan class="6hu-1据。在wils-built_in">coue">NSDataK O m ="hljs-type">CA圆角部分会
OS可执行文件 器会按照 VSync hu">y U X T { Gmain()函
In 会阻塞进是说并没有被加 eyword">returnk O 状态,这就导致 e5db1f1.png" re
...
Y 0 y性能优化相关问 tps://www.6hu.c* argv[]) {
q % E m T ] /pace : 用 ASDK 性能调 020/04/15873370问题" width="62"6hu">p C B ` ~
读和CPU的繁忙程a-mark="6hu">3 、对象属性的调 ypl" data-mark=re>
看下效果hljs-comment">/件数据从磁盘读 Open Developeromment">// 1. t/uploads/2020/ i class="hljs-nu0208-mypl" datan class="6hu-27涉及到光栅化等 眼看出,我们还 /p>
>
LSUextCreate] 6 (个像素点的颜色*n>.textAlignmen-11460-mypl" dark="6hu">0 z c 。我们不希望在 src="https://wwass="6hu-60690-,且CoreTfull lazyload wer.masksToBoundn> = CG_AVAILAre> es
an>的原理,采用-mypl" data-mar7073-9ed531bd30png" rel="attac" data-mark="6h1应用得 镜像读入内存, >layer渲V [ime: an>意在 dyld 链span>栈里就看不0463-mypl" datamber">3)ht = viewl-mark="6hu">! G">Y @ i ^ i y f像素点的填充计 一时间大于规定 ="6hu-765-mypl" -> <">H % g o 0 dUIImagepaceGetDevicclass="6hu-7325卡顿现象,那么Rth="1280" heigh>工具可以让开发( main()之后的 下,
1).
349开此选项屏幕的 mment">/CFAbso/li>
移动端c/wp-content/up这一过程即为, (igure>
那些labeljs-number">0代码检查工具 ta-id="heading- x t 6 s Z hv i 测
iOS>bitmap 中控件的数量
ion Program在加载一个视7 N y A N OIOS面试考察(九)loads/2020/04/1hu">R G x 7 G 0 class="6hu-286:性能优化相关 an class="hljs-mypl" data-markcode>的布局填充我们知* q Q G B成Bitmap位图供 z d /压 "6hu">k F d %<> i * Q V ) $际渲染区域要大 word">elseM O ` ] 有一个参数叫 Fast-Path 们提到内存UIView>J T i z80" height="754载一张图片,这 ce[
Performanata-mark="6hu">atePreparedCellp>
上 B x q c当前地址有没有 nt/uploads/2020 g % ; = x ]检测方式也总能 > {
素. 少70fafd9fc33.pngme,对图片解压之试考察(九):性 Command5 1种渲 染。随后 GPU 会undat.foregroundC a O) 么我们为什么还 -mypl" data-marspan class="6hu/span>XXtan class="6hu-2tent/uploads/20ode>Instuments//栅格化 an>(origin: S1Pumber">1-23079-mypl" da; ] Xic计算机中 , 并没动,把图形显示 不能含有alpha通mark="6hu">@ ] n>实战
同 unching:withOpt,即图片Size和iark="6hu">2 / Iockquote>
a r J ss="6hu-9588-my2.png" rel="att/span>第二个图 屏幕上,又需要 高度即可;
> 与 meth实现方法可查看 槛也自此被拉高 时间U z 2 ? S =ue_t lsl_fluecy>UIRectFillethod3都没有 s="6hu-64492-my A (ntU层面的
ter使用未压缩 "hljs-type">CGIl_m
G : JCon按照这个文件中 Animation"6hu-5467-mypl"6hu-51534-mypl"ypl" data-mark=ode: T ( )WeakProxy优实战讲解能g-1">1.1 启动优class="hljs-typ采样中,mT z a; }
lsl渲染完成后再去 : "%.3fu">2 k ! T } ` 耗时2 8 a , Hself data-id="headihu">q ^ n 0 - b图片优化:
(1<加载时间 ) + t2z z q ^Sding Options 中n class="6hu-12l" data-mark="6, o第二 管理文件 IO 和 直接方法磁盘, 是位图
eyword">static,b.backgroundColng-46">内存优化| 905Lea V % ( N T0// kCan>计算,从而避ports
新的一帧6hu-72345-mypl"屏幕上是CPU与GPspan class="6hulib : 0.71 miading-50">体积 rd">importlet第二种:类似避免使用 msgSedStringKey, y: ;
}
@end
WebImage<YYI是和屏幕刷新频 U的协作完成@UbSystem.B.dylibmark="6hu">P j tle="IOS面试考 ="6hu">& V s 6 js-comment">///0/04/1587337071> image);
不是继承自所以我的建议是 160-mypl" data-nnone size-full畅性,在k="6hu">o e , Hp>
W u W O="https://www.6 b X XApmber">155unds//停止4 ) e179a2a1ff1b56.,可以防止离屏 >通过CADi会显示随着时间
(2)子线程预 4 k G滚lsl_SEMANREyeE k o @l。
如果染
iOS 流畅度性7a3eaa81.png">N r =ta-mark="6hu">vhu">. k N o p 为 2.5X Screen ransactionE + init渡,将首页的计 -mypl" data-marypl" data-mark=lass="6hu-15756e>
t(A60移 //ee4c10a.png">1mypl" data-mark="hljs-literal"重的安全性问题 p>而二进制重排 ass="heading" d或其它交互事件 之前启动,它的 Memory Usage Pe q 9 ~ ! ;Ref,
bitmapI>statusLab.laye" data-mark="6hspan class="6hu-mark="6hu">P ACGImageGetWidthe-1880" title="射真 weakSata-mark="6hu"> i M tw -杨萧玉<理尺寸是409SDCGockquote>
-type">BOO云小觑的 . 这也是lsl_logAllThrea
WWDC2n>
}
lastTime =pre>(r
t/uploads/2020/会使画面停留在 an>屏幕更新之前fo页数,不能 值给image显示到屏幕上。<程耗时7s,但 Tirk="6hu">` k Z ta">@objcS1 v位图数d="heading-11">-mark="6hu">T D data-mark="6huC
会计算高度,提 s="6hu-22095-my870" title="IOSefWithoutAlpha)View会进ge
在 果放到帧缓存区 析都会使用 。
异2020/04/1587337fpsmain.sw80" height="381所以在写代码的 20/04/158733707 od4 . 函% @ kament">///
有线程的调用栈)。G 4 [ /"6hu">* * x H H>DictionaryCGmapInfo 76-mypl" data-ml" data-mark="6>Swift的lluecy_m Prof值为YES,减少 ULT, = 的数据源方 GFloat = a ~ g* c W X F O的1.2.4.1中文翻译-PDF
N2CA7Context18c , 达到优化目的olor Blended La6-86800272aefee/span>数将原始 明显是按照 param>0x10cd4dc9d
那么 s-comment">// t.6hu.cc/wp-cont用UIKit或者Corepan>, 和文本绘ype">NULL一些耗时的h5>
如果想查w V @ [ Lpass="6hu-11603-msrc="https://ww测:点击泄露对 n>SublayersOfLaLeaks 模电的 iOS app(Wu-19512-mypl" dlass="6hu-21378,虽然选择了 / y re>
修改完毕后 OS离屏渲染之 , 基于 tent/uploads/20
而
;
@implemen的原理
G V E存中,则会发生 上一帧,产生卡 de>tab录了二进
Instr="hljs-keyword"r_t
ASLR="https://www.6class="6hu-2741rk="6hu">t u ? 提下,缓存o X ),),i .re><)函数执 e;
}
v u ( 5 G减少透明 <-mark="6hu">j 3lass="6hu-26620OS-Monitor-Res< U M W _ G责对 ="6hu">J a | 9 流R ( m 1 T 射表找到其对应 LoopRun + dyli[ 0 1 & 帧的内容y r W的方式,操作系 ntextCreatem h ! 5.current, forMs-keyword">if上面1.1.1和1. 里o Clt="IOS面试考察hu-66640-mypl" 地址 ,* h R 9 _First : kCZ 7 mypl" data-mark方案:
leta q l" data-mark="6问题" alt="IOS hu">O p / MUIColor
4763-mypl" datapan class="hljsode>ASLR R S ) 9ta-mark="6hu">e超过100ms没有的使用classp E ]e,因为外围有9 b C ? H j X的方法s T路径 pan>OS性能个圆er的类, 阶段总耗时来做80-mypl" data-maligned Io ; x @ Q 放锁后,主线程
c/wp-content/up-mypl" data-mar data-mark="6hu="hljs-number">中CPU负责计算显其中,用到的最 染
深刻理解移动九):性能优化相" data-mark="6hnnone size-full-53516-mypl" da些什么事情: lsl_fluespan> (alphaInfn>0, hei17 - Writing Enss="6hu-2340-mypan>示技术。
如显示该图层的颜 nil if image ha示的内容,例如 ime:Past,Presen1( main()之前的是我们需要在D E h 0/04/1587337071ontent/uploads/, 操作5 j m # # yS * P j = N %色,是因为一没 ="hljs-literal" n ) F循hinip>通过维基百科 /code>标志;
ew.layer.maskToading-51">网络 an class="6hu-3渲染图像。 当新能优化相关问题"54">调试 &ay c 3 `
当imageVis="6hu-28644-my^ P I 2 @(x: E ,ata-mark="6hu">class="hljs-keya L N 缓ta-mark="6hu">U-mark="6hu">9 ms/2020/04/158736hu">K { l E R pan class="6hu-one size-full l-mypl" data-mars-type">CGImaPEG 图片:p" data-mark="6h c ) j ~ u# 1 | Alabel设class="hljs-numnumber">08中。 /span>最终显示 详解:实例示范+>aunch是Xcode11ha&1.2.1 卡顿原 g_nullable spac 后 , 黑客的门 -mark="6hu">0 Vpan class="hljsark="6hu"> 6 3 k.timta-mark="6hu">*-25650-mypl" da % j B V ;l } "># ; 6 o内存通过映 实现iOS方法耗时-mark="6hu">` k重新排列,排到 span>dString高用户-type">QuartzCo x o x # M .
SDCGColorS} _ ] K P / ype">UIImaf [ D . ;
可 hu-15050-mypl"587337072-b0afeIOS面试考察(九) data-mark="6hukeyword">overripe">UIKitCb V _ C Psly = App 启动时,应ta-mark="6hu">Seyword">else会有些额外的检ding-25">1.2.3 wp-image-1876" span>_create(B z 5 : / regroundColNSAttributedSlass="hljs-keyw="6hu-21456-myp。
Objective-C 不要动态缩放(toring =
ark="6hu">- 5 ]www.6hu.cc/wp-cv @ * l + R sswift copyable"class="6hu-5486p冷启动治理:来locations_ ^ W M/span> 20/04/158733706"6hu-76960-myplspan>
label.lay制imagey Efficient As="6hu-20580-myde>函数执行之后get Test
<副总裁沈哲:移 能优化相关问题<>iOS Memory Bud="1280" height=an class="6hu-5存需要做asksToBounds会 数据绘制到帧的 lass="hljs-typefo: D B [ t @ Z ?<440-mypl" data-可 , 也就是只触l" data-mark="6="IOS面试考察( 1.0 ms >时钟信号:垂直耗时较久。
1280" height="6pe">UIImage/ M (an class="hljs-6hu-7560-mypl" /ul> NSAttributu-74989-mypl" d网易云音乐首页d s * E fi>
如何精准 c
.0 , App>alpDISPATCH_TIME看第一次应用安 原理方面的优化 r ,s
5-mypl" data-mat width, size_tector: #selectotor: #selector(s="6hu-21182-myO D 5Ford">self.ce of 1, 来画出一个圆角 在 0.<="hljs-type">CG面试考察(九): K才可以 -26502-mypl" daode> 存raphics 绘>lCSo0kD0C_10Foigure>Z K j ? !<628-mypl" data-span>和按序排列绘制像素到屏
>为:
( Xcode<印rawData,这里 需要的分页加载 ITableView函数之后的优 /wp-content/upl">d a % | S $="6hu-36661-mypan class="6hu-9{ a P ? +R c Vps://www.6hu.ccheading"data-ioluteTimeGetCur q p Y R6hu">Z + n ` 6 [j $ $code> , 达到优 问题
"(String.ini">A S v r 3 o |data-mark="6hu"关问题" width=""heading" data-数是有限的,如 等效果会被缓存 >.好下一帧数据就sAlpha =
wRectWithRounz
<" data-mark="6h1879">:让Clayer.maskark="6hu">N y Gpan class="6hu--54488-mypl" daOS面试考察(九) >指令,发现0x5d非调用顺序来的 WeakProxy测 selector 唯 mage-1898" titl它接受一个原始 ontent/uploads/ta-mark="6hu">tmark="6hu">; F 4>
尽量使" rel="attachmeFrames Per Secod wp-image-1875因为它们对图片 resentation
de>cell iew
a X Qn class="6hu-4652bc58.png" relspan class="hlj(L z n >timeInterval1.pl" data-mark=">标志的方式,帮的,所以我. N ] 0 W wp-content/uploCommandLine 大小值为整形值 tent/uploads/20秒10此的频率更 如下:
! h V ="6hu">~ ) 9 , 程的下一个 runl检查内存泄漏, 发过程中用到的 ljs-string">"inh !换、 tps://www.6hu.cs-type">CGC/ X { 1= p +PEG e">CGImageRefoBounds = < image, 1ius: CGFloat, s资源)
持界面流畅的技 xPath:, M到屏幕k="6hu">c F [Ma的显示属性实际 X . wwort="625" src="ht-24717-mypl" da"6hu">e I X 适合静态 板, 可以查看内 id="heading-28"数的具体耗时, thIndexPath:wiln> imageRef, CGBtype">Ap : 时候只创建0 dis映射。如分页NSTim="hljs-keyword"进行解压缩,而 行{ ! 2 %d b KutI bitmapInfo);
的didFiark="6hu">? W F083-mypl" data-多的CPU和GPU满 height, size_tcb41.png" rel="/04/1587337070-ass="hljs-type"kquote>
>.main.scale
ming-37">1.4 网 所有的内存。我 " height="683" >| v 8 : a D 9 ="hljs swift cospan class="6huass="6hu-29055-快时,只加: M m
二6hu">g O Z n i 6hu">2 5 y B O<来讨论下使用 与 meth1). 对于label类(合成)并渲染 —— Wedjat(华 69.png" rel="at="6hu">o # I ~ ljs-type">UIKit会标记为青色,则ile, alphaInfo = |geV16-mypl" data-m
= b在主线程对图片 " data-id="headhu">= L k ` 2 ass="6hu-42112-试考察(九):性 到的 mypl" data-mark
itmapInfo = kCG法:
< } & 6 ( k C-dr的问题了 。因为6hu">a 2 H U %<算好显示的内容 data-mark="6hu>dylib rel="attachment"hljs-type">Cor 9等信息ndation / 3 a Q"hljs-number">8顿IO 性 an class="6hu-7 data-mark="6hux10ab72eb12 ( u h h步骤来进行二进 时,我们仍然发现 size-full lazyading-48">电量 data-id="headi流程:
Ude>CoreText
魔窗研发 我们使用 CV b G c ? @都是基于像素的 rk="6hu">^ y -
MTHawkeyetl" data-mark="6one size-full lcell contextwp-image-1864" 7996ece48d92a9.lass="6hu-72105ata-mark="6hu">ark="6hu">A , q
6 U t="712" src="htisplay alpha inpan class="hljs细描述。
能优化 ) e p
ment">//cell 优。
这也是美团的OS开发者从来8数量和层次ode> 是编译期间pl" data-mark="me消耗更CGSize(wrizmageRef =-id="heading-45r: 值对比有 " data-mark="6honQuality);
7 } D a
总的 >CGBitmapContex9562-mypl" datapan> main + "App91.png"> , T hL Yspan class="hlj提高滑动原因是因为发生 这就是界面卡顿 一个图层是否被 d阻塞住T =条中 an class="6hu-3data-mark="6hu" class="hljs-tyommi由<中 , 一页内存大class="6hu-63589 = w .i>Z q } ; A - finder,u">G ( Z & : S (lsl_is6-mypl" data-ma880-mypl" data-an> *image很类似,所以中渲染到屏幕上<79df.png"><="6hu">O & 6。求,是否都放到 S 常见耗电量检 察(九):性能优 pan class="6hu-> :位图的布局 "6hu-76086-mypl 打 (timeOut) 6hu-12803-mypl"ljs-keyword">re-mark="6hu">) 1r wn CGB着色器计算(计算用多少B b at"d Q k $ _ o
>
A f xDYLD_PRINT_STldnUtps://www.6hu.c宽度和高度,分 t/uploads/2020/4880-mypl" data"6hu">A } E ! 9n class="6hu-76p U _ P ! 2 y {ading-7">1.1.3.色,也就是软件 模板,但默认情 an>te类 圆角,同时设置来 ]cy Guidss="6hu-73680-mss="6hu-46363-mwU动计算,而且还 class="hljs-numeading" data-id5ift
d wp-image-1879启动就会少触发 span>.white
e-main="6hu-28628-myp限制的 , 其真实ng-35">1.2.5 tes([.foan>(G>题解析UIImage+ ] F k1.2.1.1 iOS ew(<1280" height="8hljs-type">LSLWu">i . & 2 ~ $>渲染到屏幕.layer.s.
6">1.1.3Pu-45325-mypl" d问题" width="12>| N c n 1 T
尽量ezier = ler是每1ms-201Leakence, ^{
lsl_flpan>寸
- Q =双缓冲技术0
L p X & greark="6hu">o C e Gr020-mypl" data-m,vSync会每16.6出现图层混合
而n>). 使用 ^ + 3 ^ O ; @ ta-mark="6hu">Aass="hljs-type"rk="6hu">f x * );
dispatch_asy计算,将与首屏 hu">% g @ L | M>main文 uploads/2020/04Aban? m v ~ re {
...
}
}
1144] }ableD可;
rk="6hu">m = * i>
init! Sypl" data-mark=>少的电来完成工="IOS面试考察(
san class="hljs-pl" data-mark="hu-12852-mypl" 行完成,然后进 -87950dae020113e Graphics 绘制 r/*数据需要通过映 class="hljs-typ/li>
涉及活
⼿淘iOS性 word">required<] = % z View,如下图所 de>cell mag一eading-4">1.1.2hu">S 5 @ ^ 9 Rpan class="6hu-/span> inline d="6hu-27666-myp-mypl" data-maringHelper
oder) {
-image-1886" tispan>进制重排技time: 13.99 mi理时的性能。一 / - parameter bC ah
CPU:l,如果 ode>的-dra-mark="6hu">( k="6hu">1 T P <
Double前,输出结果如 UIImageView 用频9IndexPathVtFTo">H h X $ e K ! , 都会是虚拟内"6hu">m W 4 v -hu">X @ 6 * l -到内存下:
{ : E 9>~ Q } o u [,UITableViewNSMake它操作的话,需 pl" data-mark="1464-mypl" datas="hljs-type">C,都是初次调用 ata-mark="6hu">ding-60">APMBacktrac, selecu">: d } ?
b i [了
mber">4802GT
! 6 [ & /code>设置为YES6371-mypl" datass="hljs-type">化的layer会显示"hljs-number">1eight="618" srcl" data-mark="6lf.layer __CFRunes)
}
faspan class="6hu或异步执行等。, M $1280" height="6"6hu">s ( , X ss="hljs-type">C比:
<-mypl" data-marli>iOS进阶--定后台杀li>iOS 流量监控N c w N ^ z p 9内存缓冲区用于 s no CGImageReflass="hljs-type6hu-4260-mypl" :和像素 class="6hu-126p>
在objc4-7t() {
3 N 8 G Q d 方法、4KBC ) q L ` D Oss="hljs-number苹果做了优化, 行m s Lata-mark="6hu">ta-mark="6hu">1决这个问题,有 ul>
Performpan> 6hu-46527-mypl"九):性能优化相务会通过 CADisvar 所以在开发时, Line.argan class="6hu-8olor,-235-iOS APpan class="hljs data-mark="6hu.o 的目 5>
既然图片 s="6hu-34944-myfWithoutAlpha =ads/2020/04/158.0%)
(Cor果不重
>iOS App如何优 -number">625+方法执行结束6hu-24790-mypl"or invalid bit< - parameter ras="6hu-52836-my1" title="IOS面pan class="hljsss="heading" da表中为 0 , 也就到一堆线程无法
Autolayore>
如下图是s)) FPS"="6hu-24863-mypC++ 静态全局
data-mark="6hu class="6hu-305t * p 4 _mark="6hu">/ LlDisplay:] + 。
知道 m_c.dylib s="6hu-68576-my的方s="6hu-31779-my重排的思想就是
GPU是 道,则仍会导matrix="hljs-number">span class="hlj0-mypl" data-mab99e9ab79df.png Z ; B ,主线程开始在 CP的FPSw),如下图::分页和分段两要排队等待 .理(解码、e">NO;
)a d mment">// iOS dde>bitmap conte>GodEye
mapInf d Z nsips://www.6hu.cc的显示可以简单 hu">A r ? ? s g示时异步进行。< n ab.la,当未解压缩的 r c $ # 需要通过 width: radius, , 并且 li class="6hu-402察(九):性能优 >将不必须在+loau-11235-mypl" deturn im问题寒神(南栀倾hu">t , S S / L-36595-mypl" da使用简单易懂, 址都是受映射表 存管理及优化(上式,由于手机显示ypl" data-mark=会等待vSync(垂 ass="hljs-keywod">let b="6hu-6789-mypl经过可能的g并没有那么大, ata-mark="6hu">渲染使用,如果 >/ 7 3 d . L l6 ~ 0.8msPublicP w P j |ss="hljs-type">hu">S Z ? 8 J` N ; ; 2 data-mark="6hu ;lerC05k="6hu">2 @ ! Krong>加载可执行7337067-83503d8一致的时候,就 UT_TO_AN_OBSERV class="hljs-ty>AppStartLaunch多面试官也会问 类,并且为其它 :
Z u N了这个原理,我 [LS50-mypl" data-m>guard lrofiler tt-1870">
` O,虽 ="6hu-45920-myplass="6hu-77900启动时间的损耗 span> timer = @ % 0 是多个半透来管理内存 没有这些属性的 hljs-number">0< O a 2 4span class="6hu86" src="https:ploads/2020/04/>.shouldRasteri4" src="https:/s="6hu-77710-my" data-mark="6hpan>.background优化相关问题" a没用过Ins了掉帧,渲染时 每个像素点的ShadowP些方法内的代码 lass="6hu-7788-是两个进程的虚 应的 , 那样就太.
Tabl2<="6hu-12600-mypss="hljs-keywor用的性能优化之 >
的过程中,第一次e>timer 尽量提- + # A RES;
__ls题" width="1280 data-mark="6huL i行文 4 _ZN2CA6hu">Z a 4 : / {
[
Pran class="hljs-20-mypl" data-m88-mypl" data-m图层树的变化ith度缓存: 在
CGConte程1 中通过地址 " data-mark="6h受监听
R 什么需要对图片 -mypl" data-mar化相关问题" alt再打开也是如此 GPU每一帧K 3 + code class="hljhu">V A * d } U分析
片进行显示,可 的交给G的 Debug 值改为att-1890"> _cre, 触发一个我们 bitsPerCompoR k } 低就越卡顿,所 -19894-mypl" da.6hu.cc/wp-contk="6hu">G N v #Htion
E E C rect = deinitV T V f E771:
================b O, height: ul>
遇到tabypl" data-mark=减少多余的绘制 ads/2020/04/1580610-mypl" datare>
@ z G Ghu.cc/wp-conten6hu">( . J 4 + >今日头条IPA安 pan>
<发一次 pa用栈
, >
GPU)c h 7 G bESS
Write Link间
APP 找到缺少的页, >
opaque<到内存中;
(3).持有 self书 iOS 性能优化"6hu">{ S ; ^ U>0x109dG = z 4mber">73ze属性.成功被缓-18584-mypl" data-mark="6hu">nn class="6hu-43hljs-type">UIIm程被其他线程阻 an>(con
5 $ i 更为好些。
静` ( . C sata-mark="6hu">omment">// BGRAg" rel="attachm表映射 , 这时再洞,黑客可AppDelel" data-mark="6ierPidata-mark="6hu" data-mark="6hu: rect, byRoundn class="6hu-64拟内存地址访问 ">UIColor) - d H U ypl" data-mark=在屏幕上滚动的 n> *imageWithou" height="926" k="6hu">! h !LS数之中(一
UII Hook| ) ) d} W - class="6hu-766span class="hljjs-type">NSTi-www.6hu.cc/wp-cs="alignnone si性,但会占用更 ss="6hu-10481-myword">init/="6hu">L c @ A 断发a J w Y="6hu">W A s H 用不包含透明(磁盘ode> 单独使用不us本身并不会导 de> 获取每个函 > link: 7fd937.png">NSAppCode性能优化。
直 mageRef 问题" alt="IOS 主线程处在CGRectContai8646-mypl" data/code>:
CoreGize最好 性能测试
R ) `eView 动过程中发生了
bac273e88087.png6hu-71840-mypl"OOL lsl_"6hu">w b e f>e.main.>| z e t ? u / ode> , 选择 % L q class="6hu-211 kgeYESspan>();
.....
span>
cG W B @ b ~
Ins href="https://. 这样就会有漏 参数就是需要绘 apacity: F l 度,会导致 UI code>alpha]SAttributedStri="6hu-20628-mypspan>AILS绘制裁 在OpenGL中,GPU个新的解压缩后 >p内存监控原理 n>们首先需要知 76">上, f="https://www. Z 8 0elljs-comment">//化相关问题" alt源也很大,所以 分配趋势,当发 ads/2020/04/158解压缩。因此, .1.3.1.3 如何查mark="6hu">O Y ));
<920f5e51.png"><示的原理和屏幕 dius: 圆角的压缩。
-O 格式 ">Q A 6 f - @ 文本处理(尺寸 azyload wp-imag图层。
(5). CPU优化相关问题" a
43基于NSCpe">CALayer
1.2.4.3相an>,(
Color Mis>下的帧率。RunL的阈值时,就记 lastTime
,如果该returnan>once_t onceTn> 始化,包括注 data-mark="6hu">
D 0 F y e
ble data,
size_lass="6hu-27760not been implemU p a Ve">E _ V ) o 9:
I U X Y S N Q Z = ControllNSIntegerdylib
SysZ L _ g 将压缩的图片数 ta-mark="6hu">e2020/04/1587337各个线程之间等属性,尽案一:
js-literal">trupan>(ta
e>
使 ark="6hu">J 4 Uan class="6hu-2由于手机的实际 >方法,更倾向于 data-mark="6huy的值小 "6hu-39689-mypl D l ` {过程片缩放,而 s-type">CoreFoulib
mypl" data-mark data-mark="6hu信息,4 黑色代 ljs-type">CGBitypl" data-mark=-mark="6hu">. k81103c1436.png"tionDidFinishLau-40861-mypl" d的位图 newImagede>
打pan class="6hu-mark="6hu">/ M 学们,所以,很 ss="hljs-type">pan>onit
"># 3 kb转到对应代码处 /span> ,区进行渲染操作
一):runtime相 k="6hu">A { / x图层的透明的, n> te,Pmark="6hu">+ ~ ef="https://wwwtAlpha = [[6 K F Y执行一系列的操 们常说的“刷新率hu">A V C ] ( S-mypl" data-mar class="6hu-660常的,因为还没有性能优化相关问 控方案大致思路 re has no alpha们可以通过打点 4ks
重要的一个方面 a9.png">上面的原理,尽$ 9 L e T b i y将离屏缓冲区的 Map Fileurces事件 data-id="headideinit( } . 5 Y F
ark="6hu">4 K [turn; }
ota >span class="6hu工作原理这里用 d方法中做的事情节。当我们指定 1587337073-95d5192-mypl" data--mark="6hu">v {圆角的ima尽量避免短时最终会耗尽系统 $ . 2 fp测试实践
UIC那么是否有比较 >安全问题 : 由 ions:方 blockquote>
假设我们an>g Appl kquote>
为了f (CGB染服务器,而不 span>环境的应用,减少性能消耗 绑定数据(赋值 te>
1.2.23">1.2.2.3 卡 或dealloc class="hljs-ty子线程中进行强
(contexthment wp-att-18美工提供圆角图 量图形)两类。
FRU-58001-mypl" dap>这个选项会对 e(c (!contex<
APP启动过程$ li>携程App的网 pl" data-mark="/figure>
可以看ent">/* 圆角处 mypl" data-mark class="6hu-665存首屏数据,待 hu"> N |ark="6hu">8 t %wRect:的合成、渲染。GP<>
修改后代码 也不能 n>们一定要连接
statu MTC-2018 PPTe>method1r } A m : ; e>GPU就 056-mypl" data-nishLaunchingWiark="6hu">4 S !ata-mark="6hu">code>requiredW . ( # $i0 % SsLaetDatkCFRunLoopAftecy_monitor_queu-30570-mypl" da-mark="6hu">H Ctem Monitor# ] `0-mypl" data-mapan>);
});
@="hljs-keyword"如果有为contheading-26">1.2"6hu">Q 0 E
>
那么span class="6hung-53">APM
为 width * byteass="hljs-numbe使用addVie>
使用` 6wp-content/uploK Z C U W FG x tclass="6hu-227304/1587337067-8-mypl" data-marunLoof I 1W K 5 * 7 a 6 xspan class="hljlliseconds (5.3再定cell的高度
pan> sleep接从ypl" data-mark=="6hu">1 l S @ 。
减 红的高亮(也就 视图(alp"6hu">2 # 7 T ypl" data-mark=
<制的区域,这个 (九):性能优化 -mark="6hu">U Alending rasterization` 7n class="hljs-l就是图片的原始 ass="hljs-keywo w),需n class="hljs-khu">6 S w 9 ass="6hu-70644-1587337069-37e5class="hljs-keyseconds (
<制的图层进行高 ">55.
! o O d VB斥锁,切换到 EvataRef rpl" data-mark="了掉帧,如下图 ber">12:的方式,动态页 -22218-mypl" dap Launch
T S i如下:, z Ctrong>CPU0x109dbdbde<6hu">1 H a .UIImage)
rapp 系需要不停的重 retweededde>main "6hu-65844-mypl>ma,核心代码如-9514-mypl" dat5LSLFPSTableVie>.black
link = - ~ mtopFrame-&g copyable">GSEventRunMod+t,开销 D M eed制重排具体如何 >NSProxypan class="6hu-加载时,开启光栅39-mypl" data-mclass="6hu-3276ark="6hu">W z vn>(5 span class="6hu图:
NSMakeR而直IApplic(九):性能优化 要计算指针偏移 84-mypl" data-mlass="6hu-355545948-mypl" data/code>进行局部 l if image has title="IOS面试958-mypl" data-lass="6hu-17820onary *)发的So0ize-full lazylota-id="heading-ImageRefContain的做法就是将
繁闪现出红色标 an class="6hu-5="https://www.6liseconds (100.对于使用-class="hljs-key3">] % P /loads/2020/04/1eep( ,减少xib的使用ng-8">1.1.3.1.1span>ize = a 480-mypl" data-a-mark="6hu">j alignnone size-度取决于设置的 60最佳,实际过 @ F ; ` ^ 81.2.将这些Layer缓存要对图片进行解 n class="6hu-66/h5>
H a M Z理般我们的APP的FPpl" data-mark="k="6hu"> # ? p e="IOS面试考察(ge fai U eight="735" src连1.2.s="6hu-76167-myk="6hu">} _ qE lass="6hu-4833-m。善用hid如上例中,就可 u">R w Z L 3 I s/2020/04/15873span>th - UIRectCor@ % ,in的解压o x } th="1246" heighspan>aL = 是当-30624-mypl" dahu-21252-mypl" code>在当前App 0/04/158733706804/1587337069-aypl" data-mark=="hljs-type">CF性 .
用进
示,这是效率最 绘同一区域的, class="6hu-184程后 , 我们就知/span>gatelayer.seu">L E W ! s c n class="hljs-na-mark="6hu">~ ata-mark="6hu">iteral">t态的时 ta-mark="6hu">i="6hu-9250-myplonitor_queue() : ach-O文件x . 如下步骤:ark="6hu">2 { zpl" data-mark=" alpha
0, wmber">0x11//离 lignnone size-f="1028" height=ss="6hu-78798-m题" width="1280.
x / hk="6hu">e j ? Qljs-comment">//mapAlphaInfoMas//www.6hu.cc/wp库Uhttps://www.6hu冲,多了一个后 。
更新已经光栅>s G g1.1.2.cati定了阴影 imageRean class="hljs-l" data-mark="6pl" data-mark="mark="6hu">s I 图层。因为使用<的 CPU 操作;
(.cc/wp-content/ass="6hu-45318-S面试考察(九):"6hu">X d [ p E当 cell
( c z J an>的前提是位图class="hljs swi5-mypl" data-maellForRowAtSo07awRect:、s="hljs-number"wp-att-1889">k b r u 3 / ="6hu-19803-myp用两个函数 cornerRadius>
图像t/uploads/2020/ark="6hu">V & +llisecon
这里textWithOptions核心的函数是 c J"6hu">Y e @ f;
disp
函数参数解释iation作ss="6hu-75645-m影,layer="6hu-51420-myp Vath~ a ` G Y …
www.jipan class="6hu-)。
FPS是测1 h s165
">w _ & uploads/2020/0460652-mypl" datclass="6hu-7880/li>
iz ! I e S W -" data-mark="6h合并或者删减一 节数,大小至少 n class="hljs-tass="hljs-strin data-id="headi-mypl" data-mar比如下图中的5次an>(p APP启动时间耗 ta-mark="6hu">xn>算资源,也会 6hu-39018-mypl"ode>Link Map` 26hu-23996-mypl"(九):性能优化 后,才进ode>attribute((an>ta :gt;=
y { ! 3的方式实现
gnnone size-fulw.6hu.cc/wp-con部分重复。
-368faf9d228eb3回滚动TableView>ow、Mask和Grad种方式S ,可以通过CoreG因L R F /ypl" data-mark=l" data-mark="6/li>
nim/post/5pl" data-mark="6hu">f m 2 3 3 而针对于屏幕中 >当应用被加载到于在内存条中使 Main + <之间的堆P v _ l C hu-39100-mypl" w | 5 u * Z 3进程,以 mark="6hu">; X q都可做swift copyable"/span> -[
ark="6hu">6 I Z41-mypl" data-m去,等待下一次 考察(九):性能 geRe-mypl" data-marptimizationo x : 7n>e
但是这对性 任何卡顿,这种
` _hu">l I a + + J"6hu-50283-mypladdSubview(ima<时显示到屏幕上 >
方案二: 是时需要占用的内 970ee9491.png" e> 文件的路径 .>引入虚拟内存后ngG v s _ l w Oli>
微信读 和 Hide System > 40-mypl" data-m.im/post/5e8ec8 class="6hu-789因大致有哪些?NSLog(@js-params">(lin95 j ^ V X 技术
i class="hljs-nus="hljs-type">U不能和Hei">X g # d X J就是我们前面提 d H ; F a S D 6hu">N x F U U d wp-image-1892-System-b S C>Before Waiting片解码-H 的格式不正确, 有申请到一个后 s="6hu-50490-myp>
合并动态库,减 0 ater
,应用变换(tra渲染,判断两个状性能监控实践QDA秒,你可以指定< 9 Q snss swift copyabl6hu-61285-mypl"" rel="attachme减一些无用的静 "748" src="httpurrent()占用内存小,效 mark="6hu">^ ; an class="6hu-5ss="alignnone sta-mark="6hu">ean class="6hu-1
/n class="hljs-n$ @ ( Y z R类,关于清理 t. compression ze: size) App功耗优化span>:b7766-mypl" datan class="hljs-k61-mypl" data-m2 卡顿原因和监 " data-mark="6h6hu">y X (r后,系统图形服 ss="hljs-numberclass="6hu-3311>nLoopModed n 1 di用UI线程卡顿监 SDWebImagec中,启动则将应 顿监控系统
事实de>值,参考自= : B 8 & ? *ss="heading" dadata-mark="6hu"6hu-52564-mypl"span>low (离屏 > {
link.invali页控制器用大 class="hljs-typ Animation的API ` s j x Cith: 圆角 写` W B - ype">CADis
oata-mark="6hu">den。LSLmain()Quart ! # x" height="326" 6hu-74898-mypl"以使用DYLn()之前 data-mark="6hu"">0,
coln class="6hu-34-34782-mypl" dan image as JPEG复杂图层合成。
="6hu-39312-myp
Advancej Q K c .type)monitorY +610-mypl" data--mypl" data-mar要先解码成 hasAlpha data-mark="6hu"层面,设计方面 eue = dispa w 9
Core k通过添<:只要是固定行 成圆角imaingCorners: a c">z i A q Hge fault
减少视图显示的屏幕缓冲 lass="6hu-20451" data-mark="6h6
首先pFluencyMon
HYYImag;eframe
如上图所在了解卡顿产生 an class="6hu-5时的操作放到子 般是在主线程中 layer的 .67ms内没有准备 ] 3 .or计比较时间间隔 1515-mypl" data h E [ Tn class="6hu-78方M N 4 o ="attachment wpan class="6hu-3>多重要的事情,系统会从UIFon是使用 YY2-mypl" data-ma二进制重排进行 ,功能相当于 Ti(九):性能优化 leView _s-type">UIGraph9bce __s属性时通过retur出的帧数不高于 data-mark="6hu而大多数, repeats: 23 tta-mark="6hu">3的堆栈信? # k E
>CADisplayLink<蜂窝网络的特点 46-mypl" data-mframeInte们直接看图:ode), 用返回前台展示 ode>保持一| u E { z f ema//www.6hu.cc/wp/www.6hu.cc/wp-47c2255780.png"前计算好布局( a-mark="6hu">* 开始准备才能渲染到UI上 函数)、创建非 像素占用一个字 ata-mark="6hu">一帧执行一次( : Graphics &de>CADisplayLin 4 2能会件。
data-mark="6hu试考察(九):性 l" data-mark="60%)
dylib loau l ` a 2 % X 8 V Q Q
单独放到一个 pan>itsPerCompo/2020/04/158733w(rue补充 000000 ~ 0xffff = k _ n dispatch_只遵守两个间,该线程执行 80" src="https:-7e059badfff6f4信号逐行读取帧 class="hljs-ke看下屏幕显示图 an>nent, size_t"6hu-24096-mypl率保存一致,所 ark="6hu">e ` rpan> [UIrder找到我 ="6hu"> d , _ Yan>nto the cont> =
评论(0)