Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
600件のPull RequestからみたXamarinのはまりどころ
Search
Nobuhiro Ito
May 07, 2016
Technology
3
4.2k
600件のPull RequestからみたXamarinのはまりどころ
2016/05/07(Sat) Japan Xamarin User Group #13 Xamarinのすべて!
Nobuhiro Ito
May 07, 2016
Tweet
Share
More Decks by Nobuhiro Ito
See All by Nobuhiro Ito
Bitriseで本をビルドする / Build a book with Bitrise
iseebi
0
130
BitriseでmacOSアプリをビルドする / Build macOS apps with Bitrise
iseebi
1
720
iOS/Androidアプリ転送ツール TransporterPadの紹介
iseebi
0
6k
Xamarinアプリとプッシュ通知
iseebi
2
1.6k
Apple Developer Enterprise Program でどこまでいけるのか
iseebi
0
730
ReactiveProperty を使ったアプリの設計に Realm Xamarin を組み合わせる
iseebi
0
610
ReactiveProperty で Xamarin アプリの作り方が変わった
iseebi
3
1.6k
Yet Another Cross Platform Development
iseebi
0
4.1k
XamarinでPDFを作る
iseebi
1
1.7k
Other Decks in Technology
See All in Technology
サービスの拡大に伴うオペレーション課題に立ち向かう / 20241128_cloudsign_pdm
bengo4com
0
760
【Oracle Cloud ウェビナー】【入門&再入門】はじめてのOracle Cloud Infrastructure [+最新情報]
oracle4engineer
PRO
2
130
Nutanixにいらっしゃいませ。Moveと仮想マシン移行のポイント紹介
shadowhat
0
220
Raspberry Pi 秋の新製品をチェックしてみよう / 20231202-rpi-jam-tokyo
akkiesoft
0
110
Postman Flowsで作るAPI連携LINE Bot
miura55
0
220
累計2500万着電を支える大規模 電話自動応答サービスのアーキテクチャ / Architecture of a Large-Scale Automated Phone Response Service Supporting 25 Million Cumulative Calls
ymachida
8
4.1k
Bytebaseで実現する データベース管理の効率化
shogo452
1
140
LINEヤフーにおける超大規模プラットフォーム実現への挑戦と学び / Challenges and Lessons in Building an Ultra-Large-Scale Platform at LY Corporation
hhiroshell
1
850
2024/11/29_失敗談から学ぶ! エンジニア向けre:Invent攻略アンチパターン集
hiashisan
0
190
AWS re:Invent 2024 予選落ちのBedrockアプデをまとめて解説!
minorun365
PRO
2
230
今はまだ小さい東京ガス内製開発チームが、これからもKubernetesと共に歩み続けるために
yussugi
3
490
AWS認定試験の長文問題を早く解くコツ
keke1234ke
0
120
Featured
See All Featured
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.6k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
27
2.1k
Rails Girls Zürich Keynote
gr2m
94
13k
Scaling GitHub
holman
458
140k
The World Runs on Bad Software
bkeepers
PRO
65
11k
What's new in Ruby 2.0
geeforr
343
31k
Designing for Performance
lara
604
68k
Making Projects Easy
brettharned
115
5.9k
Ruby is Unlike a Banana
tanoku
97
11k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Transcript
600݅ͷPull Request ͔ΒΈͨ Xamarin ·ΓϙΠϯτ Nobuhiro Ito / Fenrir Inc.
@ Japan Xamarin User Group Conference #13, 2016/05/07(Sat)
@iseebi Nobuhiro Ito Fenrir Inc. Smartphone App Engineer http://iseebi.hatenablog.com/
ձࣾͱͯ͠Xamarinྺ2Ҏ্ ా͞Μ͕XamarinऔΓѻ͍͡ΊΔલ͔ΒͬͯΔ
MvvmCross Ψν ͨͩ࠷ۙͬͱଞͷͷΛࢼ͍ͨ͠ͱࢥͬͯΔ… ※px୯ҐͰϨΠΞτࢦ͕ࣔඈΜͰ͘ΔͷͰFormsͰରॲͰ͖ͳ͍
࠷ۙͷ͓ࣄ ΞϓϦͷ։ൃͷ͔ͨΘΒɺύοέʔδͷϓϩμΫτΦʔφʔͬͯ·͢ɻ
͋ΔϓϩδΣΫτͷ͓Λ͠·͢
ϓϩδΣΫτͷཧମ੍ͷมԽ • 2011, 2012 ωΠςΟϒ / Subversion (2012ͷ్த͔ΒgitҠߦ), Redmine •
2013, 2014 Xamarin / git, Redmine, Backlog, TeamGantt • 2015 Xamarin / GitHub Enterprise, Redmine, Backlog, TeamGantt
GitHub Enterprise ʹͯ͠Α͔ͬͨ͜ͱ • શ෦ Pull Request ͰϨϏϡʔͰ͖Δ • ͋ͱ͔Β༷ʑͳ͜ͱΛৼΓฦΔ͜ͱ͕Ͱ͖Δɻ
͋ͱ͔ΒৼΓฦΔ͜ͱ͕Ͱ͖Δ • ίϛοτͷճͱ͔ • ͲΜͳίϛοτΛ͔ͨ͠ͱ͔ (શ෦ Pull Request ͰݟΕΔ)
None
4ϲ݄Ͱͪΐ͏ͲͽͬͨΓPR 600݅ ࠓ͜ͷத͔Β ಛʹʮۤ͠Μͩͳʔʯͱ͍͏ͱ͜ΖΛ ͔͍ͭ·ΜͰ͝հ
ͦͷ1 HTTPϋϯυϥෆ҆ఆࣄ݅
Hello, ModernHttpClient • աڈͷ։ൃ͔ΒɺHttpWebRequest ͩͱ Android Ͱ ·Εʹ DNS
͕1΄ͲҾ͚ͳ͘ͳΓɺ௨৴Ͱ͖ͳ͘ͳΔ͜ͱ͕Θ͔͍ͬͯͨɻ • 2015ModernHttpClientΛ͏͜ͱܾΊ͍ͯͨɻ • HttpClient ͷҾʹ͢ HttpClientHandler ͱͯ͢͠ NativeMessageHandler Λఏڙͯ͘͠ΕΔɻ • iOS 9 ͷ ATS ରԠͱͯ͠ඞਢͩͬͨɻ
iOS 8 ͔͋ΜΜ… • ModernHttpClient ͷಋೖࣗମΘΓͱ͢ΜͳΓͰ͖ͨɻ • AutomaticDecompression = true
Λࢦఆ͍ͯ͠Δͱ iOS ͰΫϥογϡ͢Δͱ͔͋ͬͨɻ • ͔͠͠ɺࠓ iOS 8 Ͱ HTTP ͕௨Βͳ͘ͳΔݱ͕ൃੜ͢Δ…
CFNetworkHandler…ࠓiOS9͕͔͋Μ… • ModernHttpClientಉ༷ʹɺHttpClientHandlerͱͯ͑͠Δ System.Net.Http.CFNetworkHandler ͕ೖ͍ͬͯͨͷͰ͏ɻ • iOS 8Ͱ҆ఆ͢Δ͕ɺiOS 9 Ͱ
https ͕௨Βͳ͘ͳͬͨɻ • iOS 8 Ҏલ CFNetworkHandlerɺ ͦΕҎ֎Ͱ NativeMessageHandler Λ ༻͢ΔΑ͏ʹ͢Δ͜ͱͰղܾɻ • NSUrlSessionHandler/AndroidClientHandler ͕ඪ४ࡌ͞Ε(Δ|ͨ)Β͍͠ͷͰظɻ J04PS&BSMJFS $'/FUXPSL)BOEMFS J04 /BUJWF.FTTBHF)BOEMFS "OESPJE /BUJWF.FTTBHF)BOEMFS
ͦͷ2 Content Description จࣈԽ͚ࣄ݅ @Android
ࣗಈςετ͠·͠ΐ͏…·͓ͨ·͔͑Galaxy! • Android ͷ UI ςετΛ͢Δ͜ͱʹͳ͍ͬͯͨͷͰɺContent Description Λࢦఆ͍ͯͨ͠ɻ • ຊͷἧ͑ͷͰ
Xamarin Test Cloud Ͱͳ͘ɺ Remote TestKit ͱUIAutomator ͷΈ߹Θͤɻ • ຊޠͷ Content Description Λࢦఆ͍ͯ͠Δͱ Galaxy S6 edge Ͱ͜ͱ͝ͱ͘??????????????ʹจࣈԽ͚ɻ • ݁ہӳޠࢦఆ͠ɺϦϦʔεલʹ͢͜ͱͰղܾɻXTC ͬͯͯʹͳΔ͔ʁ
ͦͦGalaxyͱXamarinͷ૬ੑ͕ѱ͍ • جຊతʹԿ͔͋Δͷ GalaxyɻS4, S5, S6 શ෦Ϡό͍ɻ • Galaxy S4
4.2.1 ͕ಛʹϠό͍ɻଞͷͰಈ͍͍ͯΔίʔυ͕ී௨ʹམͪΔɻ • ͦͯ͜͠ͷͳΜͱUSBσόοάͰ͖ͳ͍ʢʂʣ • ͨͩɺ͍͕ͭ͜མ͍ͪͯΔͷ্࣮ؒҧ͍ͬͯͨͱ͍͏͜ͱ͔Γͩͬͨɻ • ͖ͬͪΓςετ͍ͨ͠Ϛκͳํ1ήοτ͓ͯ͘͠ͱྑ͍͔ɻ
ͦͷ3 ARM64Ͱଈࢮࣄ݅ @Android
64bit ͷ .so ͕͋Δͱ ABI 64bit ͳ͍ͱࢮ͵ • Android൛ͰRealmґଘ͍ͯ͠ΔωΠςΟϒϥΠϒϥϦΛ͍ͬͯͨɻ
• XamarinͰ͍ͬͯͳ͔ͬͨɻωΠςΟϒϥΠϒϥϦࢀর͍ͯ͠ΔͷΈɻ • ͢ΔͱGalaxy S6ͳͲͷARM64Ͱଈࢮ͢Δ • libmonodroid.so͕ͳ͍ͱग़ͨɻΞϓϦࣗମABI͍࣋ͬͯͳ͍͕ɺ Realm ͷωΠςΟϒϥΠϒϥϦͷ .so ͕ల։͞Εͨ͜ͱͰඞཁʹͳͬͯ͠·ͬͨɻ • ΞϓϦଆ64bit ABI Λαϙʔτͤ͞Δ͜ͱͰղܾɻ
ͦͷ4 ऴྃͨͣ͠ͷը໘ͷը૾͕ ͬͯͯϝϞϦෆࣄ݅
͋ͪͪ͜Ͱىͬͨ͜ • ը૾͕ϝϞϦ্ʹͬͯϦʔΫ / OOM • ಛʹ Android ͷ AnimationDrawable
͕͠Ϳͱ͔ͬͨ
ίʔυͷதͰ࡞ͬͨΦϒδΣΫτඞͣղ์ʂ • ϑΟʔϧυʹࢀরΛ࣋ͬͨ ΦϒδΣΫτ ඞͣ Dispose/ࢀর֎͢͠Δ UIButton appendButton; public
override void ViewDidLoad () { base.ViewDidLoad (); appendButton = new UIButton(new CGRect(10,10, 200, 48)); View.AddSubview(appendButton); } protected override void Dispose(bool disposing) { if (disposing) { if (appendButton != null) { appendButton.Dispose(); appendButton = null; } } base.Dispose(disposing); }
iOSͷ߹: Image,Layer ͷதղ์͢Δ • ϓϩϑΝΠϥͰΈͨͱ͖ը૾͕͍ͬͯͨ͜ͱ͕͋Δ • ͦ͏͍͏ͱ͖ ImageView ͷ Image,
Layer.SubLayers ۭʹͯ͠ɺ RemoveFromSuperview ͢Δͱྑ͍ɻ if (HogeImageView != null) { HogeImageView.Image = null; if (HogeImageView.Layer != null) { HogeImageView.Layer.Sublayers = null; } HogeImageView.RemoveFromSuperview(); }
Android: AnimationDrawable ͷ State ղ์ • AnimationDrawable Λͬͨ߹ɺ தͷϑϨʔϜͷBitmap͕ ղ์͞Εͳ͍ͷͰɺ
ࣗͰதΛRecycleͯ͠ SetState Ͱࢀরղ์ͯ͠Δɻ void RecycleAnimationDrawable() { if (_drawableAnimation == null) { return; } for (int i = 0; i < _drawableAnimation.NumberOfFrames; ++i) { var frame = _drawableAnimation.GetFrame(i); var bitmap = frame as BitmapDrawable; if ((bitmap != null) && !bitmap.IsRecycled) { bitmap.Recycle(); bitmap.Dispose(); } frame.Callback = null; } _drawableAnimation.Callback = null; _drawableAnimation.SetState(new int[] { }); _drawableAnimation = null; }
ͦͷ5 MvvmCross ͷ ListViewAdapter Viewੜ࣌ʹແବʹηοτ͕ಈ͘ @Android
MvxListView ͷ MvxAdapter • MvxListView ༻ʹόΠϯσΟϯάՄೳͳ ViewItem Λఏڙ͢Δ Adapter •
ͦͷ··͏͜ͱɺΧελϜͯ͠͏͜ͱͰ͖Δɻ • CreateBindableView ΛΦʔόʔϥΠυ͢Δɻ • ͳ͔ͥ CreateBindableView ͷੜ࣌ʹΫϥογϡͯ͠͠·͏͜ͱ͕͋ͬͨɻ • ߲ View ͷ MvxImageView ͷதͰ SetImageDrawable(null) ͕ಈ͍͍ͯͨɻ
CreateBindableView ൈ͚Δલʹ Binding ߋ৽͞ΕΔͷμϝ protected override IMvxListItemView CreateBindableView(object dataContext, int
templateId) { var itemView = base.CreateBindableView(dataContext, templateId); var view = itemView as View; if (view != null) { var imageView = view.FindViewById<MvxImageView>(Resource.Id.timeline_image); imageView.ErrorImageResourceId = Resource.Drawable.img_live_object_loadfail; } return itemView; } %BUB$POUFYUͷ४උ͕ऴΘͬͯͳ͍λΠϛϯάͰݺΕΔ ˠը૾͕OVMM͕ೖͬͯ͘ΔՄೳੑ͕͋Δ
DataContext ॳظԽऴΘ͔ͬͯΒܨ͙ protected override IMvxListItemView CreateBindableView(object dataContext, int templateId) {
var itemView = base.CreateBindableView(null, templateId); var view = itemView as View; if (view != null) { var imageView = view.FindViewById<MvxImageView>(Resource.Id.timeline_image); imageView.ErrorImageResourceId = Resource.Drawable.img_live_object_loadfail; } itemView.DataContext = dataContext; return itemView; }
ͦͷ6 iOS 8 ͰىಈޙҰൃͷ γϟολʔԻ͕໐Βͳ͍
iOS 8 ͷγϟολʔ໐Βͳ͍όά • ຊࠃ͚ͷ iPhone ͰαΠϨϯτϞʔυʹ͍ͯͯ͠ γϟολʔԻ͕ͳΔ • ͔͠͠ɺiOS
8 Ͱ OS ىಈޙ 1 ճͷγϟολʔԻ͕໐Βͳ͍ɻ • Α͘ΒΕͨ iOS ࣗମͷόά
iOS 8 ͷॳճͷΈɺ ڧ੍తʹγϟολʔԻΛ໐Β͢ (Βͳ͍ํ͕ྑ͍) • iOS ΈࠐΈͷޮՌԻΛ໐Β͢ AudioToolBox.SystemSound •
1108 ൪Λࢦఆ͢ΔͱɺΧϝϥͱಉ݅͡Ͱγϟολʔ͕໐Δ • iOS 8 ͷఆ UIDevice.CurrentDevice.CheckSystemVersion ͰՄೳɻ • ౾ࣝɿ͜ͷϝιου Xamarin ಠ֦ࣗு
iOS 8 ͷॳճͷΈɺ ڧ੍తʹγϟολʔԻΛ໐Β͢ (Βͳ͍ํ͕ྑ͍) needDummyShutterSound = UIDevice.CurrentDevice.CheckSystemVersion(8, 0)
&& !UIDevice.CurrentDevice.CheckSystemVersion(9, 0) && !dummyShutterSoundPlayed; : : if (needDummyShutterSound) { needDummyShutterSound = false; dummyShutterSoundPlayed = true; var sound = new AudioToolbox.SystemSound(1108); sound.PlaySystemSound(); } J04Ҏ্ɺJ04Ҏ্Ͱͳ͍ ͔ͭ·ͩ໐Βͯ͠ͳ͍ TUBUJDϑΟʔϧυ ൪ͷγεςϜαϯυΛ໐Β͢
·ͱΊ
ओͳ·ΓϙΠϯτճආํ๏ • HTTP௨৴पΓ ModernHttpClient (͘͠NSUrlSessionHandler/AndroidSessionHandler)Λ͏ɻ iOS 8 ҎԼ CFNetworkHandler
Λͬͨ΄͏͕Αͦ͞͏ɻ • ࢀরͨ͠ωΠςΟϒΦϒδΣΫτ͖ͪΜͱղ์͢Δɻ ಛʹը૾पΓղ์ʹؾΛ͚ͭΔɻ • Galaxyɺઈର͍ͭ͜Կ͔͋Δɻ1 ͋Δͱσόοάʹศརɻ Xamarin Test Cloud ʹ͍ͬͺ͍͋Γͦ͏͔ͩΒ׆༻͠Α͏ɻ
͍͞͝ʹ