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
発熱から iPhone を守る
Search
Mitsuharu Emoto
November 01, 2023
Programming
0
110
発熱から iPhone を守る
モバチキ 〜Mobile Tips 共有会〜 #2
https://cyberagent.connpass.com/event/297940/
Mitsuharu Emoto
November 01, 2023
Tweet
Share
More Decks by Mitsuharu Emoto
See All by Mitsuharu Emoto
Bluetooth 制御で業務用サーマルプリンター対応アプリを作ろう
mitsuharu
0
14
iOS デバイスから始める Bluetooth 制御の業務用サーマルプリンター対応アプリの作り方
mitsuharu
0
37
iOS 開発で便利なツールたち
mitsuharu
0
190
「ゆめみ大技林 ’24」の紹介
mitsuharu
0
42
Vanilla JavaScript はマルチプラットフォームの夢を見るか
mitsuharu
0
190
技適警察24時
mitsuharu
0
120
iOS アプリ開発におけるデータストリーム超入門
mitsuharu
0
150
オープンソースで作る自己紹介ソリューション
mitsuharu
0
67
アクションボタンから始める App Intents の再入門
mitsuharu
0
290
Other Decks in Programming
See All in Programming
REXML改善のその後
naitoh
0
150
BQ+dbt+Lookerを用いた、月間800億件以上の広告リクエストに対するデータモデリング
hanon52_
4
990
オートマトン学習しろ / Do automata learning
makenowjust
3
100
2024 컴포즈 정원사
jisungbin
0
140
Rubyのobject_id
qnighy
6
1.3k
労務ドメインを快適に開発する方法 / How to Comfortably Develop in the Labor Domain
yuki21
1
250
開発を加速する共有Swift Package実践
elmetal
PRO
0
300
複雑さに立ち向かうための ソフトウェア開発入門
shiz
2
580
Regular Expressions, REXML, Automata Learning
makenowjust
0
180
Ebitengineの1vs1ゲーム WebRTCの活用
ponyo877
0
330
The Sequel to a Dream of Ruby Parser's Grammar
ydah
1
180
『ドメイン駆動設計をはじめよう』中核の業務領域
masuda220
PRO
5
840
Featured
See All Featured
For a Future-Friendly Web
brad_frost
173
9.3k
A Philosophy of Restraint
colly
202
16k
Build The Right Thing And Hit Your Dates
maggiecrowley
29
2.2k
The Cost Of JavaScript in 2023
addyosmani
39
5.1k
Imperfection Machines: The Place of Print at Facebook
scottboms
263
13k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.4k
Agile that works and the tools we love
rasmusluckow
327
20k
Optimizing for Happiness
mojombo
375
69k
No one is an island. Learnings from fostering a developers community.
thoeni
18
2.9k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
24
2k
Making the Leap to Tech Lead
cromwellryan
128
8.8k
It's Worth the Effort
3n
182
27k
Transcript
ൃ͔ΒJ1IPOFΛकΔ ߐຊޫ ϞόνΩʙ.PCJMF5JQTڞ༗ձʙ 1
ࣗݾհ w ͑ͱΈͭΔ w גࣜձࣾΏΊΈJ04ςοΫϦʔυ w ݬͷϞόνΩͷൃදऀͰ͢ w ΤϯδχΞΧϑΣʹ)),#4UVEJPΛݟʹདྷ·ͨ͠ 2
એ w ٕज़ॻయٕॻതʹͯɺٕज़ಉਓࢽʮΏ ΊΈେٕྛ` ʯΛແྉ͠·͢ʂ w ࢲʰ3FEVY4BHBGPS4XJGUʱΛॻ͖·ͨ͠ w ʢʣͷٕज़ॻయΦϑϥΠϯ։࠵
ʢାʣͷϒʔεʢ͞ʣʹډΔͷͰɺݱ ࢀՃ͞ΕΔํ͓ؾܰʹͲ͏ͧ w ΦϯϥΠϯ։࠵Ͱɺిࢠ൛͕͋ΔͷͰੋඇ 3
J1IPOFγϦʔζ͕ൃച͞Ε͕ͨ w J1IPOFγϦʔζ J04Ͱൃ͕ൃੜʂ w "4$**KQɿΞοϓϧɺʮJ1IPOF1SPʯ͕ҟৗൃ͢ΔݪҼJ04 ͷόάͳͲͩͱίϝϯτIUUQTBTDJJKQFMFN w ʮJ1IPOFʯγϦʔζͷʮ༧ΑΓ͘ͳΔʯɺʮJ04ʯͰ
ղফ͢Δͱ"QQMF*5NFEJB/&84IUUQTXXXJUNFEJBDPKQ OFXTBSUJDMFTOFXTIUNM 4
ࠓճ͚ͩ͡Όͳ͍ɺۙͳൃ w ߴෛՙͳॲཧͳͲΛߦ͍ଓ͚ͯɺJ1IPOFͷຊମԹ ͕͋ΔఔΛ͑ΔͱɺߴԹҙͷܯࠂ͕දࣔ͞ΕΔ w ࣌ؒͷ,ࡱӨͰߴԹҙ͕දࣔ͞ΕͨɺͳͲ w ͷهࣄ w ߴԹҙʂɹJ1IPOF͕͘ͳΔݪҼͱରॲ๏
*5NFEJB.PCJMFIUUQTXXXJUNFEJBDPKQ NPCJMFBSUJDMFTOFXTIUNM IUUQTXXXJUNFEJBDPKQNPCJMF BSUJDMFTOFXTIUNM 5
͞Βʹଞࣾ·ͰऔΓ্͛ͯ͘Δ w ઌͷ9JBPNJͷൃදձʹͯɺ4OBQESBHO(FOͱԹൺֱ͞ΕΔ IUUQTUXJUUFSDPNZVLJDDIJ@XPSMETUBUVT 6
ൃ͕ͨΒ͢Өڹ w ຊମͷج൘όοςϦʔʹμϝʔδΛ༩͑Δ w ಛʹϦνϜΠΦϯిԹʹݫ͘͠ɺՐࡂരൃͷՄೳੑ͕͋Δ w ਪԹdˆ༻ԹdˆอԹdˆ w αʔϚϧεϩοτϦϯάͰʢຊମϨϕϧͰʣΫϥογϡ͢Δ w
ྫྷ٫ϑΝϯͳ͍͠ɺਅՆͷ֎Ͱ͑ͳ͍ 㱯✱A㱯 7 †IUUQTDPOTVNFSIVBXFJDPNKQTVQQPSUCBUUFSZDIBSHJOH †
ൃͷղফʹऔΓΉ w ϑϨʔϜϨʔτܭࢉෛՙ͕͍ɺػೳͳॲཧΛߦ͏ w ͱ͍͑ɺҰʹϦονͳදݱॲཧ͕͑ͳ͍ͷͲ͏ͳͷ͔ʁ w ղܾͱ͍͑ʮਪଌ͢ΔͳɺܭଌͤΑʯ w J1IPOFͷൃΛܭଌͯ͠ɺൃঢ়ଶʹԠͯ͡ॲཧΛΓସ͑Δʁ w
ࠓճ͜ͷܭଌΛऔΓѻ͍·͢ 8
J1IPOFͷൃΛௐΔํ๏ w *OTUSVNFOUT w 4ZTUFN5SBDFͰ5IFSNBM4UBUFΛ֬ೝͰ͖Δ w ʢ༨ஊʣ9DPEFਖ਼͘͠ܭଌͰ͖ͳ͍ͷͰɺΛ͍·͠ΐ͏ w ൃঢ়ଶΛ"1*͔Βঢ়ଶΛऔಘɾߪಡ͢Δ w
ݱঢ়̎छྨͷऔಘํ๏͕͋ΓɺͦΕΒΛհ͠·͢ w ʢ༨ஊʣ"1*ΛௐΔͱɺΧϝϥͷ৭Թ8FBUIFS,JUͷؾԹ͕͋Δ 9
1SPDFTT*OGP w ར༻ͷใऔಘ͢Δ"1* w /PUJ fi DBUJPO$FOUFSͰൃঢ়ଶͷมԽΛݕͰ͖Δ NotificationCenter.default.addObserver( self,
selector: #selector(monitorState), name: ProcessInfo.thermalStateDidChangeNotification, object: nil ) 10
5IFSNBM4UBUF nominal 😀 ঢ়ଶਖ਼ৗൣғͰ͢ fair 😅 ঢ়ଶߴΊͰ͢ serious 🥵 ঢ়ଶߴΊͰ͢
critical 🔥 ঢ়ଶγεςϜͷੑೳʹେ͖ͳӨڹΛٴ΅͓ͯ͠ΓɺσόΠεΛ ྫྷ٫͢Δඞཁ͕͋Γ·͢ IUUQTEFWFMPQFSBQQMFDPNEPDVNFOUBUJPOGPVOEBUJPOQSPDFTTJOGPUIFSNBMTUBUF let state = ProcessInfo.processInfo.thermalState ˞ֆจࣈࢲ͕Πϝʔδͨ͠ͷൃঢ়ଶ 11
"7$BQUVSF%FWJDF w ϥΠϒϏϡʔͳͲ"7$IBQUVSF4FTTJPOͰར༻͞ΕΔஔ͔Βऔಘ͢Δ w ੲͳ͕Βͷ,70ͰมԽΛࢹ͢Δ @objc private dynamic var
videoDeviceInput: AVCaptureDeviceInput! … videoDeviceInput = try AVCaptureDeviceInput(device: videoDevice!) observe(\.videoDeviceInput.device.systemPressureState, options:.new){ [weak self] object, change in guard let self, let state = change.newValue else { return } self.monitorSystemPressureState(systemPressureState: state) } 12
4ZTUFN1SFTTVSF4UBUF-FWFM nominal 😀 γεςϜѹྗਖ਼ৗͰ͢ fair 😅 γεςϜѹྗ͕Θ͔ͣʹ্ঢ͍ͯ͠Δ serious 🥵 γεςϜѹྗ͕ඇৗʹߴ͘ͳ͍ͬͯΔ
critical 🔥 γεςϜѹྗ͕ஶ্͘͠ঢ͍ͯ͠Δ shutdown ☠ γεςϜѹྗ͕ݶքΛ͍͑ͯΔͨΊɺΩϟϓ νϟγεςϜγϟοτμϯ͍ͯ͠Δ IUUQTEFWFMPQFSBQQMFDPNEPDVNFOUBUJPOBWGPVOEBUJPOBWDBQUVSFEFWJDFTZTUFNQSFTTVSFTUBUFMFWFM let level = systemPressureState.level ˞ֆจࣈࢲ͕Πϝʔδͨ͠ͷൃঢ়ଶ 13 w ѹྗʢෛՙʣɺԹ ిྗྔͳͲ༷ʑͳ֎෦ཁ Ҽʹࠨӈ͞ΕΔ w ిؾճ࿏ʹ͓͍ͯɺҰൠ తʹʮෛՙʯͱߟ͑ ͯͳ͍Ͱ͢
4ZTUFN1SFTTVSF4UBUF'BDUPST w ཁҼݸผʹऔಘͰ͖Δ w CJUNBTL 0QUJPO4FU Ͱ ఆٛ͞ΕΔͷͰɺෳ߹త ͳཁҼΛऔಘͰ͖Δ w
1SPTTFTT*OGPʹཁҼ ͕ཉ͍͠ʂ // bitmask of values indicating the factors // contributing to the current system pressure level. let factors = systemPressureState.factors if (factors == [.systemTemperature]) { // γεςϜશମͷߴͳෛՙ } if (factors == [.peakPower]) { // γεςϜͷϐʔΫిྗཁ͕݅όοςϦʔͷిྲྀ༰ྔΛա } if (factors == [.depthModuleTemperature]) { // ਂใΛऔಘ͢ΔϞδϡʔϧ͕ߴԹͰಈ࡞ } if (factors == [.cameraTemperature]) { // ΧϝϥϞδϡʔϧ͕ߴԹͰಈ࡞ʢiOS 17 Ҏ্ͷΈʣ } 14 IUUQTEFWFMPQFSBQQMFDPNEPDVNFOUBUJPOBWGPVOEBUJPO BWDBQUVSFEFWJDFTZTUFNQSFTTVSFTUBUFGBDUPST
ൃঢ়ଶͷςετͲ͏ͬͯʁ w ࣮ػͰൃςετΛΓ͗͢Δ ͱɺϦνϜΠΦϯి͕Β ΜͰɺނো͢Δ w 9DPEF͔Β࣮ػͷൃΛγ ϛϡϨʔτͰ͖Δ w ͨͩ͠ɺ"7$BQUVSF%FWJDFͷ
ൃγϛϡϨʔτະରԠʜ 15
·ͱΊ w ෛՙ͕ߴ͍ΞϓϦΛ࡞Δ߹ɺൃঢ়ଶͷཧ͠·͠ΐ͏ w ൃ͕ݪҼͰΫϥογϡͨ͠߹ɺΫϥογϡϨϙʔτ͕ڍ͕Βͳ͍ ͜ͱ͕͋Γɺ։ൃऀࣄѲݪҼڀ໌͕Ͱ͖ͳ͍ w ετΞͰʮΫϥογϡͨ͠ͷͰ̍Ͱ͢ʯ͕૿͑Δ͔ w ࠓճհͨ͠ίʔυ(JU)VCʹ·ͱΊ͍ͯ·͢
w IUUQTHJUIVCDPNNJUTVIBSV5IFSNBM.POJUPS4BNQMF 16
ʢ͓·͚ʣՃ"1*͔Βͷߟ w J04 WJTJPO04 ͔ΒཁҼʹDBNFSB5FNQFSBUVSF͕Ճ͞Εͨ w "QQMF7JTJPO1SPʹ͚ͨ४උʁͱ༧͍ͯ͠·͢ w ຊମਖ਼໘ͷΧϝϥɺ֎͚ͷόοςϦʔͱཧతʹݯ͕Εͨ w
ൃࣄނ͕ىͬͨ͜Βେʢ௨ৗͰ͕ͩɺಛʹ7JTJPO1SP಄ ʹண͢ΔͷͰʣͳͷͰɺൃରࡦͱͯେʂ w ಄ͷۙ͘ʹݯ͕͋ΔͱମʹӨڹ͋Γͦ͏ͳͷͰҙ͠ͳ͍ͱ 17