Synchronized iPhones, Again!

Synchronized iPhones, Again!

61a68b2172503ecdf7a7f7757df56071?s=128

Tachibana Kaoru

September 21, 2020
Tweet

Transcript

  1. Synchronized iPhones, Again! iOSDC 2020 @TachibanaKaoru

  2. Aboud Me @TachibanaKaoru ϑϦʔϥϯε iOS ΤϯδχΞ ຊ೔͸ϦΞϧΞόλʔͰొஃ͠·͢ɻ

  3. ࠓ೔ͷ͓୊ ͨ͘͞ΜͷiPhone Λಉظ͢Δɻ

  4. iPhoneͷಉظ ಉظͱ͸ ͳΜΒ͔ͷωοτϫʔΫΛհͨ͠ঢ়ଶͰɺෳ਺ͷ୺຤͕ಉ͡ಈ͖Λ͢ Δ͜ͱɻ

  5. DEMO

  6. None
  7. લఏ৚݅ ʢ̍ʣ୺຤୆਺͕20~30୆ ʢ̎ʣωοτϫʔΫʹґଘ͠ͳ͍ ʢ̏ʣࣗಈతͳάϧʔϐϯά ʢ̐ʣ༗ػతͳάϧʔϐϯά

  8. લఏ৚݅ ʢ̍ʣ୺຤୆਺͕20~30୆ ٕज़త೉қ౓Λߟྀ ౰વ iPhone ΍ iPadʹݶΓ·͢ɻ

  9. લఏ৚݅ ʢ̎ʣωοτϫʔΫʹґଘ͠ͳ͍ ܞଳճઢ΍WiFi͕ͳͯ͘΋ಈ࡞͢Δɻ ͦͷ͋ͨΓͷެԂͰ΋Ωϟϯϓ৔Ͱ΋ࢁͷ্Ͱ΋େৎ෉ɻ αʔόʔϨεͰಈ࡞

  10. લఏ৚݅ ʢ̏ʣࣗಈతͳάϧʔϐϯά ΞϓϦΛىಈ͢ΔͱࣗಈతʹάϧʔϓΛܗ੒͢Δɻ ʮˎˎͷάϧʔϓʹࢀՃ͠·͔͢ʁʯͱ͔ฉ͔ͳ͍ɻ Ϣʔβʔ͕खಈͰొ࿥͢Δ͜ͱ͸ͳ͘ɺࣗಈͰ઀ଓ͢Δɻ

  11. લఏ৚݅ ʢ̐ʣ༗ػతͳάϧʔϐϯά άϧʔϓʹ్த͔ΒͰ΋ࢀՃͰ͖Δ Ͳͷϝϯόʔ͕཭୤ͯ͠΋ɺάϧʔϓ͕γʔϜϨεʹܧଓ͢Δɻ

  12. Demo Movie ߹ܭ35୆ͷiPhoneͷө૾͕ಉ ظ͢ΔσϞө૾Ͱ͕͢……

  13. Demo Movie ͝ΊΜͳ͍͞ɻ ͜Ε͸ARͰ͢ɻ

  14. Demo Movie Reality Composer File + Xcode Ͱߏ੒ͨ͠AR ΞϓϦ Ͱ͢ɻ

  15. RealityComposer Apple੡ͷ3Dฤूπʔϧ 3DΦϒδΣΫτͷ഑ஔ΍Ξχϝʔγϣϯ ͷઃఆͳͲ͕ՄೳͰ͢ɻ ෳࡶͳϞσϦϯά͸Ͱ͖·ͤΜ͕ɺ͙͢࢖ ͑Δ਺ेछྨͷϞσϧؚ͕·Ε͍ͯ·͢ɻ ؆୯ͳARɾ3DΞϓϦΛͭ͘Δͷʹదͯ͠ ͍·͢ɻ

  16. RealityComposerͱXcodeͷ࿈ܞ RealityComposerଆ͔ΒXcodeͷΞΫγϣϯΛىಈɻ Xcode͔ΒRealityComposerଆ΁NotificationΛૹ৴ɻ ʢInterfaceBuilderͰIBActionΛఆٛ͠ɺͦͷActionத਎Λ࣮૷͢Δͷͱࣅ ͍ͯ·͢ɻʣ Notification Action

  17. VideoMaterial iOS14.0Ҏ߱Ͱ͸ɺRealityComposerͰɺಈըΛ࠶ੜ͢ΔVideoMaterial Λ ࢖͏͜ͱ͕Ͱ͖·͢ɻ ෺ମͷද໘Ͱ޷͖ͳө૾Λ࠶ੜ͢Δ͜ͱ͕Ͱ͖·͢ɻ

  18. Demo Movie App RealityComposer Ͱɺ35ݸͷࠇ͍ϓ ϨʔτͷΦϒδΣΫτΛ࡞੒ɻ RealityCopomserଆͰɺBehaviorΛઃఆ ͠ɺͲΕ͔ΛClickͨ͠ΒXcodeଆͷ Action͕ىಈ͢ΔΑ͏ʹ͍ͯ͠·͢ɻ

  19. Demo Movie App XcodeଆͷActionͰɺ͋Β͔͡ ΊࡱӨͯ͋ͬͨ͠ಈըΛηο τͨ͠VideoMaterialΛࠇ͍ϓ ϨʔτΦϒδΣΫτʹͷͤͯ ͍·͢ɻ

  20. VideoMaterial ͷੜ੒ var videoMaterial: VideoMaterial? if let url = Bundle.main.url(forResource:

    "movie", withExtension: "mp4"){ let item = AVPlayerItem(asset: AVAsset(url: url)) let player = AVPlayer(playerItem: item) videoMaterial = VideoMaterial(avPlayer: player) }
  21. VideoMaterialͷEntityͷ௥Ճ boxAnchor.actions.addMovieToiPhone.onAction = { entity in self.videoMaterial?.avPlayer?.play() let thinBox =

    MeshResource.generateBox( width: 0.125, height: 0.01, depth: 0.065) let screenEntity = ModelEntity( mesh: thinBox, materials: [self.videoMaterial!]) entity?.addChild(screenEntity) }
  22. Demo Movie App ӈͷө૾Ͱ͸ARΞϓϦͰ࣮ݱ ͠·͕ͨ͠ɺ͜Εͱಉ͜͡ͱ Λ࣮ࡍͷ୺຤ͱ࣮ࡍͷΞϓϦ Ͱ΍ͬͯΈΑ͏ɺͱ͍͏ͷ͕ ࠓ೔ͷ͓୊Ͱ͢ɻ ͜ͷϓϨθϯͷऴΘΓʹ͸ɺ ຊ෺ͷΞϓϦΛಈ࡞ͤͨ͞σ

    ϞΛ͓ݟͤ͠·͢ɻ
  23. લఏ৚݅ ʢ̍ʣ୺຤୆਺͕20~30୆ ʢ̎ʣωοτϫʔΫʹґଘ͠ͳ͍ ʢ̏ʣࣗಈతͳάϧʔϐϯά ʢ̐ʣ༗ػతͳάϧʔϐϯά

  24. લఏ৚݅ ʢ̍ʣ୺຤୆਺͕20~30୆ ʢ̎ʣωοτϫʔΫʹґଘ͠ͳ͍ ʢ̏ʣࣗಈతͳάϧʔϐϯά ʢ̐ʣ༗ػతͳάϧʔϐϯά

  25. Plan A : Core Bluetooth ۙڑ཭ແઢͱ͍͑͹Bluetooth पғͷແઢঢ়گʹґଘͤͣʹɺ୺຤ؒͰ௨৴Λ͢Δ͜ͱ͕Ͱ͖·͢ ͜ΕͰάϧʔϐϯάΛߦͬͯΈ·͢ɻ

  26. Grouping with CoreBT CBCentral CBPeripheral CBCentral CBCentral CBCentral

  27. Grouping with CoreBT Core BluetoothͰ͸̍ηογϣϯͷ୺຤ͷ্ݶ਺͕͋Γ·͢ɻ ؀ڥ΍σόΠεʹ΋ΑΔ͕ɺ͍͍ͩͨ̐ʙ̑୆͘Β͍ɻ ʢલఏ৚݅̍ΛΫϦΞͰ͖·ͤΜʣ

  28. Plan B : Core BT & Core BT Core Bluetooth

    Ͱෳ਺ηογϣϯΛߟ͑ͯΈ·͠ΐ͏
  29. Double Session ?

  30. Double Session ?

  31. Sessions in Core Bluetooth Core Bluetooth Ͱ͸ɺ1ϓϩηε͋ͨΓԼهͷηογϣϯ͔࣋ͯ͠ͳ͍ Peripheralͱͯ͠ͷηογϣϯ : 1

    Centralͱͯ͠ͷηογϣϯ : 1
  32. Double Session

  33. Double Session ͜ͷ୺຤͸ Peripheralͱ CentralΛ͔ͶΔɻ

  34. Double Session ͜ͷߏ੒͕ಈ͚͹ 20୆ఔ౓ͷάϧʔ ϓ͕࡞੒Ͱ͖Δ͸ ͣ……ɻ

  35. ࣮૷ͯ͠Έ·ͨ͠ɻ

  36. Double Session πϦʔߏ଄ͷά ϧʔϓ͸ܗ੒Ͱ͖ ͨ΋ͷͷɺඇৗʹ ෆ҆ఆ

  37. Ͳ͏͠Α͏……ɻ

  38. ͦͷλΠϛϯάͰ88%$

  39. ωοτϫʔΫϥϘͰ૬ஊͯ͠Έ·ͨ͠

  40. Plan C : Multipeer Connectivity ʮ ……ͬͯײ͡ͰωοτϫʔΫΛ࡞Γ͍ͨΜ͚ͩͲ͍͍Ҋ͋Δʁʯ : ͦΕͳΒ Multiplier

    Connectivity͕͍͍Αʂ
  41. Plan C : Multipeer Connectivity Multipeer Connectivity͸ɺωοτϫʔΫϨΠϠʔͱͯ͠Bluetooth·ͨ͸ peer to peer

    WiFiΛ࢖͍ͬͯ·͢ɻ
  42. Multipeer Connectivity Apple Engineer ʹΑΔͱɺݱࡏͰ͸΄ͱΜͲͷ୺຤Ͱ peer to peer WiFi Λ࢖͍ͬͯΔͦ͏ɻ

    1ηογϣϯ͋ͨΓͷ୺຤਺͸ެশ̓ʙ̔୆ ෳ਺ͷηογϣϯΛ࣋ͭ͜ͱ͕Ͱ͖Δɻ
  43. Single session network

  44. Double session network

  45. Double Session with MC ࣮૷ͯ͠Έͨͱ͜Ζɺ̎ͭͷηογϣϯͰ҆ఆͨ͠௨৴Λߦ͏͜ͱ͕Ͱ ͖·ͨ͠ɻ

  46. લఏ৚݅ ʢ̍ʣ୺຤୆਺͕20~30୆ ʢ̎ʣωοτϫʔΫʹґଘ͠ͳ͍ ʢ̏ʣࣗಈతͳάϧʔϐϯά ʢ̐ʣ༗ػతͳάϧʔϐϯά

  47. લఏ৚݅ ʢ̍ʣ୺຤୆਺͕20~30୆ ʢ̎ʣωοτϫʔΫʹґଘ͠ͳ͍ ʢ̏ʣࣗಈతͳάϧʔϐϯά ʢ̐ʣ༗ػతͳάϧʔϐϯά

  48. MultipeerConnectivity Network ֤୺຤͸ɺ઀ଓ༻ͷ unique ͳ Peer IDΛੜ੒͠·͢ɻ(MCPeerID) ֤୺຤͸ɺMCNearbyServiceAdvertiserͰɺपғʹΞυόλΠζΛ͠·͢ɻ MCNearbyServiceBrowserΛ࢖͏ͱɺपғͷΞυόλΠζΛ͍ͯ͠Δ୺຤ Λൃݟ͢Δ͜ͱ͕Ͱ͖·͢ɻ

    ୺຤A͔Βɺ୺຤B΁઀ଓ͢Δ৔߹ʹ͸ɺηογϣϯΛ࡞੒͠ɺInvitation ΛA͔ΒB΁ૹ৴͢ΔɻB͕InvitationΛड୚͢Δͱηογϣϯ͕੒ཱ͢Δɻ
  49. ΞυόλΠζ /// पғ΁Advertise͠·͢ɻ var advertiser: MCNearbyServiceAdvertiser? advertiser = MCNearbyServiceAdvertiser( ɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹpeer:

    myID, discoveryInfo: ["DeviceName":deviceName], serviceType: serviceID) advertiser?.delegate = self advertiser?.startAdvertisingPeer() BEWFSUJTJOH
  50. पғͷ୺຤ͷ୳ࡧ /// BrowserΛ࡞੒͠ɺपғͷ୺຤Λ୳ࡧ͠·͢ɻ var serviceBrowser: MCNearbyServiceBrowser? serviceBrowser = MCNearbyServiceBrowser(peer: myPeer,

    serviceType: serviceID) serviceBrowser?.delegate = self serviceBrowser?.startBrowsingForPeers() /// delegateͰݟ͚ͭͨ୺຤Λ֬ೝ͢Δ͜ͱ͕Ͱ͖·͢ɻ func browser(_ browser: MCNearbyServiceBrowser, foundPeer peerID: MCPeerID, withDiscoveryInfo info: [String : String]?) { } BEWFSUJTJOH CSPXTJOH
  51. ଞͷ୺຤΁ͷ઀ଓ serviceBrowser?.invitePeer(peer, to: session, withContext: nil, timeout: 10.0) BEWFSUJTJOH CSPXTJOH

    TFOE JOWJUBUJPO
  52. Ϧʔμʔ୺຤͔ΒInvitationΛૹΔ

  53. None
  54. Ͳͷ୺຤͕Ϧʔμʔʁ

  55. Ϧʔμʔͷܾఆ PeerID Λ Random ͳ Int PeerID ͷେখͰϦʔμʔΛܾఆ

  56. ىಈʜʜ

  57.        ֤ࣗ*%ΛऔಘɺΞυόλΠζ

  58.        पғͷ୺຤ͷ*%Λ୳ࡧ͠ɺʮʯ ͕ϦʔμʔͰ͋ΔͱΘ͔Δ पғͷ୺຤ͷ*%Λ୳ࡧ͠ɺࣗ෼͕

    ϦʔμʔͰ͋ΔͱΘ͔Δɻ
  59.        ͭͷηογϣϯΛ࡞Γɺͦ ΕͧΕ*OWJUBUJPOΛૹ৴

  60.        session A session

    B
  61. લఏ৚݅ ʢ̍ʣ୺຤୆਺͕20~30୆ ʢ̎ʣωοτϫʔΫʹґଘ͠ͳ͍ ʢ̏ʣࣗಈతͳάϧʔϐϯά ʢ̐ʣ༗ػతͳάϧʔϐϯά

  62. લఏ৚݅ ʢ̍ʣ୺຤୆਺͕20~30୆ ʢ̎ʣωοτϫʔΫʹґଘ͠ͳ͍ ʢ̏ʣࣗಈతͳάϧʔϐϯά ʢ̐ʣ༗ػతͳάϧʔϐϯά

  63. άϧʔϓܗ੒ޙͷΠϕϯτ ৽ͨͳ୺຤ͷࢀՃ άϧʔϓ͔Βͷ୺຤ͷ཭୤

  64. ৽ͨͳ୺຤ͷࢀՃ ϦʔμʔΑΓऑ͍୺຤ ϦʔμʔΑΓڧ͍୺຤

  65. Ϧʔμʔ୺຤ΑΓऑ͍୺຤ͷࢀՃ        session A

    session B 
  66. Ϧʔμʔ୺຤ΑΓڧ͍୺຤ͷࢀՃ        session A

    session B 
  67. Ϧʔμʔ୺຤ΑΓڧ͍୺຤ͷࢀՃ         طଘͷηογϣϯΛ

    ͍ͬͨΜऴྃ
  68. Ϧʔμʔ୺຤ΑΓڧ͍୺຤ͷࢀՃ         ࠶౓ɺपғͷ୺຤ͷ

    ୳ࡧΛߦ͏ɻ
  69. Ϧʔμʔ୺຤ΑΓڧ͍୺຤ͷࢀՃ        

  70. Ϧʔμʔ୺຤ΑΓڧ͍୺຤ͷࢀՃ         ৽ͨͳηογϣϯͷ࡞੒

  71. άϧʔϓ͔Βͷ୺຤ͷ཭୤ ϦʔμʔҎ֎͕཭୤ Ϧʔμʔ͕཭୤

  72. ϦʔμʔҎ֎ͷ୺຤ͷ཭୤ ϦʔμʔҎ֎͕཭୤

  73. ϦʔμʔҎ֎ͷ୺຤ͷ཭୤ ϦʔμʔҎ֎͕཭୤ͯ͠΋ ηογϣϯ͸ܧଓ͢Δ

  74. Ϧʔμʔͷ཭୤ Ϧʔμʔ͕཭୤

  75. Ϧʔμʔͷ཭୤ Ϧʔμʔ͕཭୤͢Δͱ ೋͭͷηογϣϯʹଐ͢Δ୺຤͕ͳ͘ͳͬͯ͠·͏ ͨΊɺωοτϫʔΫ͕ܧଓͰ͖ͳ͍

  76.        session A session

    B
  77.       session A session B

  78.      

  79.      

  80.      

  81. ༗ػతͳάϧʔϐϯά ͜ΕͰԼهͷΠϕϯτͷ͢΂ͯʹରԠ͠ɺࣗݾ૊৫Խ͢Δάϧʔϐϯάͱ ͳΓ·ͨ͠ɻ ϦʔμʔΑΓऑ͍୺຤ͷࢀՃ ϦʔμʔΑΓڧ͍୺຤ͷࢀՃ Ϧʔμʔͷ཭୤ ϦʔμʔҎ֎ͷ୺຤ͷ཭୤

  82. άϧʔϐϯάͷલఏ৚݅ ʢ̍ʣ୺຤୆਺͕20~30୆ ʢ̎ʣωοτϫʔΫʹґଘ͠ͳ͍ ʢ̏ʣࣗಈతͳάϧʔϐϯά ʢ̐ʣ༗ػతͳάϧʔϐϯά

  83. ʢຊ෺ͷʣDEMO

  84. None
  85. άϧʔϐϯάશମͷΠϕϯτઃܭ ࣮ࡍͷάϧʔϐϯάॲཧʹ͸ɺ៛ີͳάϧʔϓશମઃܭ͕ඞཁ MultipeerConnectivityͷෳ਺ηογϣϯͷΠϕϯτͷϋϯυϦϯά ͢΂ͯͷ୺຤ͷϢʔβʔೖྗͷϋϯυϦϯά ͦͷଞγεςϜΠϕϯτ

  86. άϧʔϐϯάશମͷΠϕϯτઃܭ άϧʔϓશମͷΠϕϯτϧʔϓΛϦʔμʔ୺຤Ͱઃܭ͠ɺ௨ৗͷΠϕϯτ ϧʔϓͱ͸ผʹ؅ཧ͢Δ͜ͱ͕๬·͍͠ɻ

  87. Ԡ༻

  88. MCͷ double session Ͱ Eternal Network

  89. MCͷ double session Ͱ Tree Network 73 iPhones!

  90. iPhone 73୆ iPhone 11 ͷ࠷҆Ϟσϧ 74,800ԁʢ੫ผʣ 73୆ͩͱɺ੫ࠐΈͰ̒̌̌ສ̒̐̐̌ԁ ࢿ͕ۚू·ͬͨΒݺΜͰ͍ͩ͘͞ɻ

  91. ·ͱΊ MultiPeer Connectivityͷෳ਺ηογϣϯΛ׆༻͢Δ͜ͱʹΑΓɺଟ਺ͷ୺຤Λ ಉظ͢Δ͜ͱ͕Ͱ͖·͢ɻ ࣗݾ૊৫Խ͢ΔάϧʔϐϯάઃܭΛߦ͏৔߹ʹ͸ηογϣϯͷ୺຤ͷࢀՃɾ཭ ୤ॲཧʹ஫ҙ͢Δඞཁ͕͋Γ·͢ɻ ARΛ࢖͏ͱ೔ৗੜ׆ͷதͰͷΞϓϦར༻ DEMO Λ؆୯ʹ࡞Ε·͢ɻ ϦΞϧΞόλʔͰͷొஃ͸ݟͨ໨ΑΓͣͬͱϋʔυͰ͢ɻࢎܽʹͳΓͦ͏Ͱ

    ͢ɻ͓͢͢Ί͠·ͤΜɻ