5. Why We Use Open Source
5
Scale
Pinterest has significantly fewer iOS engineers than Facebook
1
Speed
Move quickly from prototype to production
2
Reliability
Open source projects are often old and well tested
3
6.
7. Open Source At Pinterest
7
Over 15 open source projects
Pinball: A scalable workflow manager
Secor: A service implementing Kafka log persistence
PINCache: Fast non-deadlocking parallel object cache for iOS and OS X
8. Open Source on iOS
• AFNetworking
• PINCache
• PINRemoteImage
• FLAnimatedImage
• Kingpin
• Masonry
• AsyncDisplayKit
• Pop
• Realm
Just some of the great projects we use
8
2:50 PM 100%
9. 9
target 'PINRemoteImage', :exclusive => true do
pod "PINRemoteImage", :path => "../"
pod "PINCache", '2.0'
pod "libwebp"
end
target 'PINRemoteImage Tests', :exclusive => true
do
pod "PINRemoteImage", :path => "../"
end
Package Management
with CocoaPods
Specify version numbers.
Run `pod outdated` regularly.
20. 20
Testing
Continuous Testing
• Unit tests around processing code and
models
• Continuous Integration testing around
core library interactions
• UI Automation tests around core flows
User Testing
• Nightly internal builds for all employees
• Small contracted team does user testing
nightly
• Core team tests rigorously before release
21. Deadlocks
• Possibly stuck in a loop
• Probably blocked waiting on another thread
• Sometimes caused by a corrupted UI
• Thread explosion when using queues as
locks
• Dogfood with a deadlock detector
21
22. Thread explosion
The dark side of using a serial queue as a lock
22
Main Thread Serial Queue
Create a threadx100
waiting…
waiting…
Concurrent Queue
23. Deadlocks
• Possibly stuck in a loop
• Probably blocked waiting on another thread
• Sometimes caused by a corrupted UI
• Thread explosion when using queues as
locks
• Dogfood with a deadlock detector
23
24. Monitoring
• Log everything
• API requests
• Client side usage
• Performance
• Monitor to spot problems
• App Store ratings
• Crash rates
• Usage metrics
24
25. Experimenting
• Everything is an experiment
• Short and long term analyses
• You are the only one desperate for your new
feature
25
30. PINRemoteImage
• Image downloading (obviously)
• Image caching (on disk and in memory)
• De-duping image downloads
• Setting download and processing priority
• Prefetching images
• Image decompression off the main thread
A thread safe, performant, feature rich image fetcher
30
31. Multi-format Support
• JPEG
• Progressive decoding
• PNG
• WebP
• FLAnimatedImage
Supports downloading a variety of
formats:
31
33. Progressive JPEG
With an attractive blur
33
A mother with her son
Dejan Muazer
Cats
1
A mother with her son
Dejan Muazer
Cats
2
A mother with her son
Dejan Muazer
Cats
3
A mother with her son
Dejan Muazer
Cats
4
34. 34
Progressive JPEG
With an attractive blur
UIImageView *imageView = [[UIImageView alloc] init];
[imageView setUpdateWithProgress:YES];
[imageView setImageFromURL:
[NSURL URLWithString:@"http://pinterest.com/progressiveKitten.jpg"]];