问:
The app crashes some seconds after launching on iOS 9.2.1 via Testflight
I distributed my app over Testflight: The app crashes some seconds after launching on iPhone 6s running iOS 9.2.1.

But when installing the app using Xcode on iPhone 6s - 9.2.1 devices, everything works fine too.

When launching the app using Xcode and distributed my app over Testflight on an other iPhone 6s running the latest 10.3.2 everything works fine.

If i testing wia testflight ios 9.2.1 app crashes every time at random time. Crash log show me absolutly difference reason at every crash

we are using Crashlytics and it has reported over 800 crashes, each one of those a singular crash that points to either an internal apple framework or private API. Some crash points to on our codes.

Most generated bug is:

```<code># Crashlytics - plaintext stacktrace downloaded by Bkm ex at Sun, 04 Jun 2017 08:52:13 GMT
# URL: https://fabric.io/bkm-exs-projects/ios/apps/com.bkm.bkmexpressmobil/issues/5930ff20be077a4dcc8f95eb?time=last-seven-days/sessions/31c087d822b54534be973ada2bcc9f33_c0df8f95488b11e7a54356847afe9799_0_v2
# Platform: ios
# Version: N/A
# Issue #: 212
# Issue ID: 5930ff20be077a4dcc8f95eb
# Session ID: 31c087d822b54534be973ada2bcc9f33_c0df8f95488b11e7a54356847afe9799_0_v2
# Date: 2017-06-03T18:37:00Z
# OS Version: 9.2.0 (13C75)
# Device: iPhone 6
# RAM Free: 3.1%
# Disk Free: 3.3%

#1. Crashed: com.apple.root.user-interactive-qos
0  libsystem_malloc.dylib         0x180f03be8 szone_free + 2944
1  libsystem_malloc.dylib         0x180f03738 szone_free + 1744
2  CoreFoundation                 0x1812159a4 CFRelease + 1088
3  CoreFoundation                 0x181254d38 readDataFinalize + 28
4  CoreFoundation                 0x1812f9d98 __CFStreamDeallocate + 128
5  CoreFoundation                 0x181215664 CFRelease + 256
6  CoreUI                         0x185e4fb90 __69-[_CSIRenditionBlockData expandCSIBitmapData:fromSlice:makeReadOnly:]_block_invoke + 640
7  libdispatch.dylib              0x180d89630 _dispatch_call_block_and_release + 24
8  libdispatch.dylib              0x180d895f0 _dispatch_client_callout + 16
9  libdispatch.dylib              0x180d97a88 _dispatch_root_queue_drain + 2140
10 libdispatch.dylib              0x180d97224 _dispatch_worker_thread3 + 112
11 libsystem_pthread.dylib        0x180f9d470 _pthread_wqthread + 1092
12 libsystem_pthread.dylib        0x180f9d020 start_wqthread + 4

--

#0. com.apple.main-thread
0  libsystem_kernel.dylib         0x180ebd4f8 semaphore_wait_trap + 8
1  libdispatch.dylib              0x180d9aa38 _dispatch_group_wait_slow + 260
2  CoreUI                         0x185e4f818 -[_CSIRenditionBlockData expandCSIBitmapData:fromSlice:makeReadOnly:] + 892
3  CoreUI                         0x185e560a0 __csiCompressImageProviderCopyImageBlockSetWithOptions + 1136
4  CoreGraphics                   0x1825c8390 img_blocks_create + 372
5  CoreGraphics                   0x1825b9dc8 img_data_lock + 1336
6  CoreGraphics                   0x1825b8e90 CGSImageDataLock + 140
7  libRIP.A.dylib                 0x192d7d670 ripc_AcquireImage + 732
8  libRIP.A.dylib                 0x192d7ca7c ripc_DrawImage + 620
9  CoreGraphics                   0x182625884 CGContextDrawImageWithOptions + 456
10 UIKit                          0x1860397e4 -[UIImage drawInRect:blendMode:alpha:] + 1404
11 UIKit                          0x186171620 -[UIImage(UIImageInternal) _isInvisibleAndGetIsTranslucent:] + 320
12 UIKit                          0x1860bfe78 -[_UINavigationBarBackground updateBackgroundImage] + 1292
13 UIKit                          0x1861c3744 -[UINavigationBar setBackgroundImage:forBarPosition:barMetrics:] + 528
14 BKM_Mobil                      0x100176178 -[BKMNavigationController viewDidLoad] (BKMNavigationController.m:23)
15 UIKit                          0x1860280c0 -[UIViewController loadViewIfRequired] + 996
16 UIKit                          0x186027cc4 -[UIViewController view] + 28
17 UIKit                          0x18602eab4 -[UIWindow addRootViewControllerViewIfPossible] + 76
18 UIKit                          0x18602bfa0 -[UIWindow _setHidden:forced:] + 252
19 UIKit                          0x1860a1cd0 -[UIWindow makeKeyAndVisible] + 48
20 BKM_Mobil                      0x1001033f4 -[BKMAppDelegate loginViewLoad:withTouchIdIsShow:forceLoad:] (BKMAppDelegate.m:324)
21 BKM_Mobil                      0x1001020c8 -[BKMAppDelegate application:didFinishLaunchingWithOptions:] (BKMAppDelegate.m:157)
22 UIKit                          0x18609d704 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 400
23 UIKit                          0x1862cc130 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2904
24 UIKit                          0x1862d04b8 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1672
25 UIKit                          0x1862cd5c0 -[UIApplication workspaceDidEndTransaction:] + 168
26 FrontBoardServices             0x1828eb790 -[FBSSerialQueue _performNext] + 184
27 FrontBoardServices             0x1828ebb10 -[FBSSerialQueue _performNextFromRunLoopSource] + 56
28 CoreFoundation                 0x1812ecefc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
29 CoreFoundation                 0x1812ec990 __CFRunLoopDoSources0 + 540
30 CoreFoundation                 0x1812ea690 __CFRunLoopRun + 724
31 CoreFoundation                 0x181219680 CFRunLoopRunSpecific + 384
32 UIKit                          0x186096580 -[UIApplication _run] + 460
33 UIKit                          0x186090d90 UIApplicationMain + 204
34 BKM_Mobil                      0x1000e3688 main (main.m:10)
35 libdispatch.dylib              0x180dba8b8 (Missing)

#1. Crashed: com.apple.root.user-interactive-qos
0  libsystem_malloc.dylib         0x180f03be8 szone_free + 2944
1  libsystem_malloc.dylib         0x180f03738 szone_free + 1744
2  CoreFoundation                 0x1812159a4 CFRelease + 1088
3  CoreFoundation                 0x181254d38 readDataFinalize + 28
4  CoreFoundation                 0x1812f9d98 __CFStreamDeallocate + 128
5  CoreFoundation                 0x181215664 CFRelease + 256
6  CoreUI                         0x185e4fb90 __69-[_CSIRenditionBlockData expandCSIBitmapData:fromSlice:makeReadOnly:]_block_invoke + 640
7  libdispatch.dylib              0x180d89630 _dispatch_call_block_and_release + 24
8  libdispatch.dylib              0x180d895f0 _dispatch_client_callout + 16
9  libdispatch.dylib              0x180d97a88 _dispatch_root_queue_drain + 2140
10 libdispatch.dylib              0x180d97224 _dispatch_worker_thread3 + 112
11 libsystem_pthread.dylib        0x180f9d470 _pthread_wqthread + 1092
12 libsystem_pthread.dylib        0x180f9d020 start_wqthread + 4

#2. com.apple.libdispatch-manager
0  libsystem_kernel.dylib         0x180ed94fc kevent_qos + 8
1  libdispatch.dylib              0x180d9c94c _dispatch_mgr_invoke + 232
2  libdispatch.dylib              0x180d8b7bc _dispatch_source_invoke + 50

#3. com.twitter.crashlytics.ios.work-queue :: NSOperation 0x126ea1510 (QOS: LEGACY)
0  libsystem_kernel.dylib         0x180ebd4f8 semaphore_wait_trap + 8
1  libdispatch.dylib              0x180d9a55c _dispatch_semaphore_wait_slow + 244
2  CFNetwork                      0x18198c584 -[__NSURLBackgroundSession setupBackgroundSession] + 540
3  CFNetwork                      0x18198bd34 -[__NSURLBackgroundSession initWithConfiguration:delegate:delegateQueue:] + 412
4  CFNetwork                      0x181a31130 +[NSURLSession sessionWithConfiguration:delegate:delegateQueue:] + 560
5  BKM_Mobil                      0x10024c904 +[CLSURLSession sessionWithConfiguration:delegate:delegateQueue:] + 4296902916
6  BKM_Mobil                      0x10022beac -[CLSNetworkClient session] + 4296769196
7  BKM_Mobil                      0x10022cf28 __76-[CLSNetworkClient checkForExistingTaskMatchingDescription:completionBlock:]_block_invoke + 4296773416
8  Foundation                     0x181cdc334 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 16
9  Foundation                     0x181c2f100 -[NSBlockOperation main] + 96
10 Foundation                     0x181c1f348 -[__NSOperationInternal _start:] + 604
11 Foundation                     0x181cde728 __NSOQSchedule_f + 224
12 libdispatch.dylib              0x180d895f0 _dispatch_client_callout + 16
13 libdispatch.dylib              0x180d95634 _dispatch_queue_drain + 864
14 libdispatch.dylib              0x180d8d0f4 _dispatch_queue_invoke + 464
15 libdispatch.dylib              0x180d97504 _dispatch_root_queue_drain + 728
16 libdispatch.dylib              0x180d97224 _dispatch_worker_thread3 + 112
17 libsystem_pthread.dylib        0x180f9d470 _pthread_wqthread + 1092
18 libsystem_pthread.dylib        0x180f9d020 start_wqthread + 4

#4. AXBinaryMonitorQueue
0  libsystem_kernel.dylib         0x180ebd4f8 semaphore_wait_trap + 8
1  libsystem_platform.dylib       0x180f9697c _os_semaphore_wait + 24
2  libdispatch.dylib              0x180d944ec _dispatch_barrier_sync_f_slow + 560
3  AccessibilityUtilities         0x18a46a1b0 __46-[AXBinaryMonitor _addHandler:withName:toMap:]_block_invoke + 128
4  libdispatch.dylib              0x180d89630 _dispatch_call_block_and_release + 24
5  libdispatch.dylib              0x180d895f0 _dispatch_client_callout + 16
6  libdispatch.dylib              0x180d95634 _dispatch_queue_drain + 864
7  libdispatch.dylib              0x180d8d0f4 _dispatch_queue_invoke + 464
8  libdispatch.dylib              0x180d895f0 _dispatch_client_callout + 16
9  libdispatch.dylib              0x180d97a88 _dispatch_root_queue_drain + 2140
10 libdispatch.dylib              0x180d97224 _dispatch_worker_thread3 + 112
11 libsystem_pthread.dylib        0x180f9d470 _pthread_wqthread + 1092
12 libsystem_pthread.dylib        0x180f9d020 start_wqthread + 4

#5. Thread
0  libsystem_kernel.dylib         0x180ed8b6c __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x180f9d530 _pthread_wqthread + 1284
2  libsystem_pthread.dylib        0x180f9d020 start_wqthread + 4

#6. Thread
0  libsystem_kernel.dylib         0x180ed8b6c __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x180f9d530 _pthread_wqthread + 1284
2  libsystem_pthread.dylib        0x180f9d020 start_wqthread + 4

#7. com.twitter.crashlytics.ios.MachExceptionServer
0  BKM_Mobil                      0x10022ae00 CLSProcessRecordAllThreads + 4296764928
1  BKM_Mobil                      0x10022ae00 CLSProcessRecordAllThreads + 4296764928
2  BKM_Mobil                      0x10022b220 CLSProcessRecordAllThreads + 4296765984
3  BKM_Mobil                      0x10021bed4 CLSHandler + 4296703700
4  BKM_Mobil                      0x100217214 CLSMachExceptionServer + 4296684052
5  libsystem_pthread.dylib        0x180f9fb28 _pthread_body + 156
6  libsystem_pthread.dylib        0x180f9fa8c _pthread_body + 154
7  libsystem_pthread.dylib        0x180f9d028 thread_start + 4

#8. com.google.gmp.measurement.worker
0  libsystem_kernel.dylib         0x180ebe80c pread + 8
1  libsqlite3.dylib               0x181877334 (null) + 3192
2  libsqlite3.dylib               0x1817f8b9c (null) + 13664
3  libsqlite3.dylib               0x181817b3c (null) + 5504
4  libsqlite3.dylib               0x181816ab8 (null) + 1276
5  libsqlite3.dylib               0x181888ffc (null) + 76096
6  libsqlite3.dylib               0x181837abc (null) + 50004
7  libsqlite3.dylib               0x18182b960 sqlite3_step + 504
8  BKM_Mobil                      0x10025c314 -[FIRASqliteStore validateDatabaseWithError:] + 4296966932
9  BKM_Mobil                      0x10025c22c -[FIRASqliteStore openAndValidateDatabase:] + 4296966700
10 BKM_Mobil                      0x1002596e4 -[FIRASqliteStore initWithDatabasePath:] + 4296955620
11 BKM_Mobil                      0x1002639e8 -[FIRADatabase initWithDatabaseName:persistedConfig:] + 4296997352
12 BKM_Mobil                      0x100271264 __48-[FIRAMeasurement startMeasurementOnWorkerQueue]_block_invoke + 4297052772
13 libdispatch.dylib              0x180d895f0 _dispatch_client_callout + 16
14 libdispatch.dylib              0x180d8a434 dispatch_once_f + 80
15 BKM_Mobil                      0x100270f48 -[FIRAMeasurement startMeasurementOnWorkerQueue] + 4297051976
16 BKM_Mobil                      0x100270d3c -[FIRAMeasurement setIsEnabledOnWorkerQueue:] + 4297051452
17 BKM_Mobil                      0x10028282c __52-[FIRAScheduler scheduleOnWorkerQueueBlockID:block:]_block_invoke + 4297123884
18 libdispatch.dylib              0x180d89630 _dispatch_call_block_and_release + 24
19 libdispatch.dylib              0x180d895f0 _dispatch_client_callout + 16
20 libdispatch.dylib              0x180d95634 _dispatch_queue_drain + 864
21 libdispatch.dylib              0x180d8d0f4 _dispatch_queue_invoke + 464
22 libdispatch.dylib              0x180d97504 _dispatch_root_queue_drain + 728
23 libdispatch.dylib              0x180d97224 _dispatch_worker_thread3 + 112
24 libsystem_pthread.dylib        0x180f9d470 _pthread_wqthread + 1092
25 libsystem_pthread.dylib        0x180f9d020 start_wqthread + 4

#9. com.twitter.crashlytics.ios.binary-images
0  libsystem_kernel.dylib         0x180ebd5b8 syscall_thread_switch + 8
1  libsystem_platform.dylib       0x180f99534 _os_lock_handoff_lock_slow + 120
2  libsystem_malloc.dylib         0x180f04920 szone_free_definite_size + 684
3  libdispatch.dylib              0x180d895f0 _dispatch_client_callout + 16
4  libdispatch.dylib              0x180d95634 _dispatch_queue_drain + 864
5  libdispatch.dylib              0x180d8d0f4 _dispatch_queue_invoke + 464
6  libdispatch.dylib              0x180d895f0 _dispatch_client_callout + 16
7  libdispatch.dylib              0x180d97a88 _dispatch_root_queue_drain + 2140
8  libdispatch.dylib              0x180d97224 _dispatch_worker_thread3 + 112
9  libsystem_pthread.dylib        0x180f9d470 _pthread_wqthread + 1092
10 libsystem_pthread.dylib        0x180f9d020 start_wqthread + 4

#10. Thread
0  libsystem_kernel.dylib         0x180ed8b6c __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x180f9d530 _pthread_wqthread + 1284
2  libsystem_pthread.dylib        0x180f9d020 start_wqthread + 4

#11. com.apple.NSURLConnectionLoader
0  libsystem_kernel.dylib         0x180ebd4bc mach_msg_trap + 8
1  libsystem_kernel.dylib         0x180ebd338 mach_msg + 72
2  CoreFoundation                 0x1812ecac0 __CFRunLoopServiceMachPort + 196
3  CoreFoundation                 0x1812ea7c4 __CFRunLoopRun + 1032
4  CoreFoundation                 0x181219680 CFRunLoopRunSpecific + 384
5  CFNetwork                      0x181989434 +[NSURLConnection(Loader) _resourceLoadLoop:] + 412
6  Foundation                     0x181cf7c40 __NSThread__start__ + 1000
7  libsystem_pthread.dylib        0x180f9fb28 _pthread_body + 156
8  libsystem_pthread.dylib        0x180f9fa8c _pthread_body + 154
9  libsystem_pthread.dylib        0x180f9d028 thread_start + 4

#12. Thread
0  libsystem_kernel.dylib         0x180ed8b6c __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x180f9d530 _pthread_wqthread + 1284
2  libsystem_pthread.dylib        0x180f9d020 start_wqthread + 4

#13. Thread
0  libsystem_kernel.dylib         0x180ed8440 __semwait_signal + 8
1  libsystem_c.dylib              0x180df522c nanosleep + 212
2  libc++.1.dylib                 0x18096e314 std::__1::this_thread::sleep_for(std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&) + 84
3  JavaScriptCore                 0x184b09bf4 bmalloc::Heap::scavenge(std::__1::unique_lock<bmalloc::StaticMutex>&, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000l> >) + 188
4  JavaScriptCore                 0x184b098a4 bmalloc::Heap::concurrentScavenge() + 84
5  JavaScriptCore                 0x184b0bde4 bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::*)()>::entryPoint() + 100
6  JavaScriptCore                 0x184b0bd74 bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::*)()>::pthreadEntryPoint(void*) + 12
7  libsystem_pthread.dylib        0x180f9fb28 _pthread_body + 156
8  libsystem_pthread.dylib        0x180f9fa8c _pthread_body + 154
9  libsystem_pthread.dylib        0x180f9d028 thread_start + 4

#14. WebThread
0  libsystem_kernel.dylib         0x180ed7f90 __psynch_mutexwait + 8
1  libsystem_pthread.dylib        0x180fa239c _pthread_mutex_lock_wait + 96
2  libsystem_pthread.dylib        0x180fa257c _pthread_mutex_lock_slow + 296
3  WebCore                        0x184dcba2c _WebTryThreadLock(bool) + 128
4  WebCore                        0x184dcb98c WebRunLoopLock(__CFRunLoopObserver*, unsigned long, void*) + 44
5  CoreFoundation                 0x1812ec588 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
6  CoreFoundation                 0x1812ea32c __CFRunLoopDoObservers + 372
7  CoreFoundation                 0x1812ea65c __CFRunLoopRun + 672
8  CoreFoundation                 0x181219680 CFRunLoopRunSpecific + 384
9  WebCore                        0x184dc9738 RunWebThread(void*) + 456
10 libsystem_pthread.dylib        0x180f9fb28 _pthread_body + 156
11 libsystem_pthread.dylib        0x180f9fa8c _pthread_body + 154
12 libsystem_pthread.dylib        0x180f9d028 thread_start + 4

#15. JavaScriptCore::Marking
0  libsystem_kernel.dylib         0x180ed7f48 __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x180f9ece8 _pthread_cond_wait + 648
2  libc++.1.dylib                 0x180930074 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 56
3  JavaScriptCore                 0x1848b8a90 JSC::GCThread::waitForNextPhase() + 144
4  JavaScriptCore                 0x1848b8b28 JSC::GCThread::gcThreadMain() + 84
5  JavaScriptCore                 0x18458e634 WTF::threadEntryPoint(void*) + 212
6  JavaScriptCore                 0x18458e544 WTF::wtfThreadEntryPoint(void*) + 24
7  libsystem_pthread.dylib        0x180f9fb28 _pthread_body + 156
8  libsystem_pthread.dylib        0x180f9fa8c _pthread_body + 154
9  libsystem_pthread.dylib        0x180f9d028 thread_start + 4

#16. com.apple.CFSocket.private
0  libsystem_kernel.dylib         0x180ed8368 __select + 8
1  CoreFoundation                 0x1812f3028 __CFSocketManager + 648
2  libsystem_pthread.dylib        0x180f9fb28 _pthread_body + 156
3  libsystem_pthread.dylib        0x180f9fa8c _pthread_body + 154
4  libsystem_pthread.dylib        0x180f9d028 thread_start + 4
</code>```

答:
It is very interesting bug. I use a image which is "Screen Shot 2017-05-12 at 03.03.24.png" on xcassets. So this image causes random crashes on iOS 9.2.1 and lower iOS 9

I should not have use image name which is contain point.
I lost my weekend :(

Body:
I distributed my app over Testflight: The app crashes some seconds after launching on iPhone 6s running iOS 9.2.1.

But when installing the app using Xcode on iPhone 6s - 9.2.1 devices, everything works fine too.

When launching the app using Xcode and distributed my app over Testflight on an other iPhone 6s running the latest 10.3.2 everything works fine.

If i testing wia testflight ios 9.2.1 app crashes every time at random time. Crash log show me absolutly difference reason at every crash

we are using Crashlytics and it has reported over 800 crashes, each one of those a singular crash that points to either an internal apple framework or private API. Some crash points to on our codes.

Most generated bug is:

# Crashlytics - plaintext stacktrace downloaded by Bkm ex at Sun, 04 Jun 2017 08:52:13 GMT
# URL: https://fabric.io/bkm-exs-projects/ios/apps/com.bkm.bkmexpressmobil/issues/5930ff20be077a4dcc8f95eb?time=last-seven-days/sessions/31c087d822b54534be973ada2bcc9f33_c0df8f95488b11e7a54356847afe9799_0_v2
# Platform: ios
# Version: N/A
# Issue #: 212
# Issue ID: 5930ff20be077a4dcc8f95eb
# Session ID: 31c087d822b54534be973ada2bcc9f33_c0df8f95488b11e7a54356847afe9799_0_v2
# Date: 2017-06-03T18:37:00Z
# OS Version: 9.2.0 (13C75)
# Device: iPhone 6
# RAM Free: 3.1%
# Disk Free: 3.3%

#1. Crashed: com.apple.root.user-interactive-qos
0  libsystem_malloc.dylib         0x180f03be8 szone_free + 2944
1  libsystem_malloc.dylib         0x180f03738 szone_free + 1744
2  CoreFoundation                 0x1812159a4 CFRelease + 1088
3  CoreFoundation                 0x181254d38 readDataFinalize + 28
4  CoreFoundation                 0x1812f9d98 __CFStreamDeallocate + 128
5  CoreFoundation                 0x181215664 CFRelease + 256
6  CoreUI                         0x185e4fb90 __69-[_CSIRenditionBlockData expandCSIBitmapData:fromSlice:makeReadOnly:]_block_invoke + 640
7  libdispatch.dylib              0x180d89630 _dispatch_call_block_and_release + 24
8  libdispatch.dylib              0x180d895f0 _dispatch_client_callout + 16
9  libdispatch.dylib              0x180d97a88 _dispatch_root_queue_drain + 2140
10 libdispatch.dylib              0x180d97224 _dispatch_worker_thread3 + 112
11 libsystem_pthread.dylib        0x180f9d470 _pthread_wqthread + 1092
12 libsystem_pthread.dylib        0x180f9d020 start_wqthread + 4

--

#0. com.apple.main-thread
0  libsystem_kernel.dylib         0x180ebd4f8 semaphore_wait_trap + 8
1  libdispatch.dylib              0x180d9aa38 _dispatch_group_wait_slow + 260
2  CoreUI                         0x185e4f818 -[_CSIRenditionBlockData expandCSIBitmapData:fromSlice:makeReadOnly:] + 892
3  CoreUI                         0x185e560a0 __csiCompressImageProviderCopyImageBlockSetWithOptions + 1136
4  CoreGraphics                   0x1825c8390 img_blocks_create + 372
5  CoreGraphics                   0x1825b9dc8 img_data_lock + 1336
6  CoreGraphics                   0x1825b8e90 CGSImageDataLock + 140
7  libRIP.A.dylib                 0x192d7d670 ripc_AcquireImage + 732
8  libRIP.A.dylib                 0x192d7ca7c ripc_DrawImage + 620
9  CoreGraphics                   0x182625884 CGContextDrawImageWithOptions + 456
10 UIKit                          0x1860397e4 -[UIImage drawInRect:blendMode:alpha:] + 1404
11 UIKit                          0x186171620 -[UIImage(UIImageInternal) _isInvisibleAndGetIsTranslucent:] + 320
12 UIKit                          0x1860bfe78 -[_UINavigationBarBackground updateBackgroundImage] + 1292
13 UIKit                          0x1861c3744 -[UINavigationBar setBackgroundImage:forBarPosition:barMetrics:] + 528
14 BKM_Mobil                      0x100176178 -[BKMNavigationController viewDidLoad] (BKMNavigationController.m:23)
15 UIKit                          0x1860280c0 -[UIViewController loadViewIfRequired] + 996
16 UIKit                          0x186027cc4 -[UIViewController view] + 28
17 UIKit                          0x18602eab4 -[UIWindow addRootViewControllerViewIfPossible] + 76
18 UIKit                          0x18602bfa0 -[UIWindow _setHidden:forced:] + 252
19 UIKit                          0x1860a1cd0 -[UIWindow makeKeyAndVisible] + 48
20 BKM_Mobil                      0x1001033f4 -[BKMAppDelegate loginViewLoad:withTouchIdIsShow:forceLoad:] (BKMAppDelegate.m:324)
21 BKM_Mobil                      0x1001020c8 -[BKMAppDelegate application:didFinishLaunchingWithOptions:] (BKMAppDelegate.m:157)
22 UIKit                          0x18609d704 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 400
23 UIKit                          0x1862cc130 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2904
24 UIKit                          0x1862d04b8 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1672
25 UIKit                          0x1862cd5c0 -[UIApplication workspaceDidEndTransaction:] + 168
26 FrontBoardServices             0x1828eb790 -[FBSSerialQueue _performNext] + 184
27 FrontBoardServices             0x1828ebb10 -[FBSSerialQueue _performNextFromRunLoopSource] + 56
28 CoreFoundation                 0x1812ecefc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
29 CoreFoundation                 0x1812ec990 __CFRunLoopDoSources0 + 540
30 CoreFoundation                 0x1812ea690 __CFRunLoopRun + 724
31 CoreFoundation                 0x181219680 CFRunLoopRunSpecific + 384
32 UIKit                          0x186096580 -[UIApplication _run] + 460
33 UIKit                          0x186090d90 UIApplicationMain + 204
34 BKM_Mobil                      0x1000e3688 main (main.m:10)
35 libdispatch.dylib              0x180dba8b8 (Missing)

#1. Crashed: com.apple.root.user-interactive-qos
0  libsystem_malloc.dylib         0x180f03be8 szone_free + 2944
1  libsystem_malloc.dylib         0x180f03738 szone_free + 1744
2  CoreFoundation                 0x1812159a4 CFRelease + 1088
3  CoreFoundation                 0x181254d38 readDataFinalize + 28
4  CoreFoundation                 0x1812f9d98 __CFStreamDeallocate + 128
5  CoreFoundation                 0x181215664 CFRelease + 256
6  CoreUI                         0x185e4fb90 __69-[_CSIRenditionBlockData expandCSIBitmapData:fromSlice:makeReadOnly:]_block_invoke + 640
7  libdispatch.dylib              0x180d89630 _dispatch_call_block_and_release + 24
8  libdispatch.dylib              0x180d895f0 _dispatch_client_callout + 16
9  libdispatch.dylib              0x180d97a88 _dispatch_root_queue_drain + 2140
10 libdispatch.dylib              0x180d97224 _dispatch_worker_thread3 + 112
11 libsystem_pthread.dylib        0x180f9d470 _pthread_wqthread + 1092
12 libsystem_pthread.dylib        0x180f9d020 start_wqthread + 4

#2. com.apple.libdispatch-manager
0  libsystem_kernel.dylib         0x180ed94fc kevent_qos + 8
1  libdispatch.dylib              0x180d9c94c _dispatch_mgr_invoke + 232
2  libdispatch.dylib              0x180d8b7bc _dispatch_source_invoke + 50

#3. com.twitter.crashlytics.ios.work-queue :: NSOperation 0x126ea1510 (QOS: LEGACY)
0  libsystem_kernel.dylib         0x180ebd4f8 semaphore_wait_trap + 8
1  libdispatch.dylib              0x180d9a55c _dispatch_semaphore_wait_slow + 244
2  CFNetwork                      0x18198c584 -[__NSURLBackgroundSession setupBackgroundSession] + 540
3  CFNetwork                      0x18198bd34 -[__NSURLBackgroundSession initWithConfiguration:delegate:delegateQueue:] + 412
4  CFNetwork                      0x181a31130 +[NSURLSession sessionWithConfiguration:delegate:delegateQueue:] + 560
5  BKM_Mobil                      0x10024c904 +[CLSURLSession sessionWithConfiguration:delegate:delegateQueue:] + 4296902916
6  BKM_Mobil                      0x10022beac -[CLSNetworkClient session] + 4296769196
7  BKM_Mobil                      0x10022cf28 __76-[CLSNetworkClient checkForExistingTaskMatchingDescription:completionBlock:]_block_invoke + 4296773416
8  Foundation                     0x181cdc334 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 16
9  Foundation                     0x181c2f100 -[NSBlockOperation main] + 96
10 Foundation                     0x181c1f348 -[__NSOperationInternal _start:] + 604
11 Foundation                     0x181cde728 __NSOQSchedule_f + 224
12 libdispatch.dylib              0x180d895f0 _dispatch_client_callout + 16
13 libdispatch.dylib              0x180d95634 _dispatch_queue_drain + 864
14 libdispatch.dylib              0x180d8d0f4 _dispatch_queue_invoke + 464
15 libdispatch.dylib              0x180d97504 _dispatch_root_queue_drain + 728
16 libdispatch.dylib              0x180d97224 _dispatch_worker_thread3 + 112
17 libsystem_pthread.dylib        0x180f9d470 _pthread_wqthread + 1092
18 libsystem_pthread.dylib        0x180f9d020 start_wqthread + 4

#4. AXBinaryMonitorQueue
0  libsystem_kernel.dylib         0x180ebd4f8 semaphore_wait_trap + 8
1  libsystem_platform.dylib       0x180f9697c _os_semaphore_wait + 24
2  libdispatch.dylib              0x180d944ec _dispatch_barrier_sync_f_slow + 560
3  AccessibilityUtilities         0x18a46a1b0 __46-[AXBinaryMonitor _addHandler:withName:toMap:]_block_invoke + 128
4  libdispatch.dylib              0x180d89630 _dispatch_call_block_and_release + 24
5  libdispatch.dylib              0x180d895f0 _dispatch_client_callout + 16
6  libdispatch.dylib              0x180d95634 _dispatch_queue_drain + 864
7  libdispatch.dylib              0x180d8d0f4 _dispatch_queue_invoke + 464
8  libdispatch.dylib              0x180d895f0 _dispatch_client_callout + 16
9  libdispatch.dylib              0x180d97a88 _dispatch_root_queue_drain + 2140
10 libdispatch.dylib              0x180d97224 _dispatch_worker_thread3 + 112
11 libsystem_pthread.dylib        0x180f9d470 _pthread_wqthread + 1092
12 libsystem_pthread.dylib        0x180f9d020 start_wqthread + 4

#5. Thread
0  libsystem_kernel.dylib         0x180ed8b6c __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x180f9d530 _pthread_wqthread + 1284
2  libsystem_pthread.dylib        0x180f9d020 start_wqthread + 4

#6. Thread
0  libsystem_kernel.dylib         0x180ed8b6c __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x180f9d530 _pthread_wqthread + 1284
2  libsystem_pthread.dylib        0x180f9d020 start_wqthread + 4

#7. com.twitter.crashlytics.ios.MachExceptionServer
0  BKM_Mobil                      0x10022ae00 CLSProcessRecordAllThreads + 4296764928
1  BKM_Mobil                      0x10022ae00 CLSProcessRecordAllThreads + 4296764928
2  BKM_Mobil                      0x10022b220 CLSProcessRecordAllThreads + 4296765984
3  BKM_Mobil                      0x10021bed4 CLSHandler + 4296703700
4  BKM_Mobil                      0x100217214 CLSMachExceptionServer + 4296684052
5  libsystem_pthread.dylib        0x180f9fb28 _pthread_body + 156
6  libsystem_pthread.dylib        0x180f9fa8c _pthread_body + 154
7  libsystem_pthread.dylib        0x180f9d028 thread_start + 4

#8. com.google.gmp.measurement.worker
0  libsystem_kernel.dylib         0x180ebe80c pread + 8
1  libsqlite3.dylib               0x181877334 (null) + 3192
2  libsqlite3.dylib               0x1817f8b9c (null) + 13664
3  libsqlite3.dylib               0x181817b3c (null) + 5504
4  libsqlite3.dylib               0x181816ab8 (null) + 1276
5  libsqlite3.dylib               0x181888ffc (null) + 76096
6  libsqlite3.dylib               0x181837abc (null) + 50004
7  libsqlite3.dylib               0x18182b960 sqlite3_step + 504
8  BKM_Mobil                      0x10025c314 -[FIRASqliteStore validateDatabaseWithError:] + 4296966932
9  BKM_Mobil                      0x10025c22c -[FIRASqliteStore openAndValidateDatabase:] + 4296966700
10 BKM_Mobil                      0x1002596e4 -[FIRASqliteStore initWithDatabasePath:] + 4296955620
11 BKM_Mobil                      0x1002639e8 -[FIRADatabase initWithDatabaseName:persistedConfig:] + 4296997352
12 BKM_Mobil                      0x100271264 __48-[FIRAMeasurement startMeasurementOnWorkerQueue]_block_invoke + 4297052772
13 libdispatch.dylib              0x180d895f0 _dispatch_client_callout + 16
14 libdispatch.dylib              0x180d8a434 dispatch_once_f + 80
15 BKM_Mobil                      0x100270f48 -[FIRAMeasurement startMeasurementOnWorkerQueue] + 4297051976
16 BKM_Mobil                      0x100270d3c -[FIRAMeasurement setIsEnabledOnWorkerQueue:] + 4297051452
17 BKM_Mobil                      0x10028282c __52-[FIRAScheduler scheduleOnWorkerQueueBlockID:block:]_block_invoke + 4297123884
18 libdispatch.dylib              0x180d89630 _dispatch_call_block_and_release + 24
19 libdispatch.dylib              0x180d895f0 _dispatch_client_callout + 16
20 libdispatch.dylib              0x180d95634 _dispatch_queue_drain + 864
21 libdispatch.dylib              0x180d8d0f4 _dispatch_queue_invoke + 464
22 libdispatch.dylib              0x180d97504 _dispatch_root_queue_drain + 728
23 libdispatch.dylib              0x180d97224 _dispatch_worker_thread3 + 112
24 libsystem_pthread.dylib        0x180f9d470 _pthread_wqthread + 1092
25 libsystem_pthread.dylib        0x180f9d020 start_wqthread + 4

#9. com.twitter.crashlytics.ios.binary-images
0  libsystem_kernel.dylib         0x180ebd5b8 syscall_thread_switch + 8
1  libsystem_platform.dylib       0x180f99534 _os_lock_handoff_lock_slow + 120
2  libsystem_malloc.dylib         0x180f04920 szone_free_definite_size + 684
3  libdispatch.dylib              0x180d895f0 _dispatch_client_callout + 16
4  libdispatch.dylib              0x180d95634 _dispatch_queue_drain + 864
5  libdispatch.dylib              0x180d8d0f4 _dispatch_queue_invoke + 464
6  libdispatch.dylib              0x180d895f0 _dispatch_client_callout + 16
7  libdispatch.dylib              0x180d97a88 _dispatch_root_queue_drain + 2140
8  libdispatch.dylib              0x180d97224 _dispatch_worker_thread3 + 112
9  libsystem_pthread.dylib        0x180f9d470 _pthread_wqthread + 1092
10 libsystem_pthread.dylib        0x180f9d020 start_wqthread + 4

#10. Thread
0  libsystem_kernel.dylib         0x180ed8b6c __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x180f9d530 _pthread_wqthread + 1284
2  libsystem_pthread.dylib        0x180f9d020 start_wqthread + 4

#11. com.apple.NSURLConnectionLoader
0  libsystem_kernel.dylib         0x180ebd4bc mach_msg_trap + 8
1  libsystem_kernel.dylib         0x180ebd338 mach_msg + 72
2  CoreFoundation                 0x1812ecac0 __CFRunLoopServiceMachPort + 196
3  CoreFoundation                 0x1812ea7c4 __CFRunLoopRun + 1032
4  CoreFoundation                 0x181219680 CFRunLoopRunSpecific + 384
5  CFNetwork                      0x181989434 +[NSURLConnection(Loader) _resourceLoadLoop:] + 412
6  Foundation                     0x181cf7c40 __NSThread__start__ + 1000
7  libsystem_pthread.dylib        0x180f9fb28 _pthread_body + 156
8  libsystem_pthread.dylib        0x180f9fa8c _pthread_body + 154
9  libsystem_pthread.dylib        0x180f9d028 thread_start + 4

#12. Thread
0  libsystem_kernel.dylib         0x180ed8b6c __workq_kernreturn + 8
1  libsystem_pthread.dylib        0x180f9d530 _pthread_wqthread + 1284
2  libsystem_pthread.dylib        0x180f9d020 start_wqthread + 4

#13. Thread
0  libsystem_kernel.dylib         0x180ed8440 __semwait_signal + 8
1  libsystem_c.dylib              0x180df522c nanosleep + 212
2  libc++.1.dylib                 0x18096e314 std::__1::this_thread::sleep_for(std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&) + 84
3  JavaScriptCore                 0x184b09bf4 bmalloc::Heap::scavenge(std::__1::unique_lock<bmalloc::StaticMutex>&, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000l> >) + 188
4  JavaScriptCore                 0x184b098a4 bmalloc::Heap::concurrentScavenge() + 84
5  JavaScriptCore                 0x184b0bde4 bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::*)()>::entryPoint() + 100
6  JavaScriptCore                 0x184b0bd74 bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::*)()>::pthreadEntryPoint(void*) + 12
7  libsystem_pthread.dylib        0x180f9fb28 _pthread_body + 156
8  libsystem_pthread.dylib        0x180f9fa8c _pthread_body + 154
9  libsystem_pthread.dylib        0x180f9d028 thread_start + 4

#14. WebThread
0  libsystem_kernel.dylib         0x180ed7f90 __psynch_mutexwait + 8
1  libsystem_pthread.dylib        0x180fa239c _pthread_mutex_lock_wait + 96
2  libsystem_pthread.dylib        0x180fa257c _pthread_mutex_lock_slow + 296
3  WebCore                        0x184dcba2c _WebTryThreadLock(bool) + 128
4  WebCore                        0x184dcb98c WebRunLoopLock(__CFRunLoopObserver*, unsigned long, void*) + 44
5  CoreFoundation                 0x1812ec588 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
6  CoreFoundation                 0x1812ea32c __CFRunLoopDoObservers + 372
7  CoreFoundation                 0x1812ea65c __CFRunLoopRun + 672
8  CoreFoundation                 0x181219680 CFRunLoopRunSpecific + 384
9  WebCore                        0x184dc9738 RunWebThread(void*) + 456
10 libsystem_pthread.dylib        0x180f9fb28 _pthread_body + 156
11 libsystem_pthread.dylib        0x180f9fa8c _pthread_body + 154
12 libsystem_pthread.dylib        0x180f9d028 thread_start + 4

#15. JavaScriptCore::Marking
0  libsystem_kernel.dylib         0x180ed7f48 __psynch_cvwait + 8
1  libsystem_pthread.dylib        0x180f9ece8 _pthread_cond_wait + 648
2  libc++.1.dylib                 0x180930074 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 56
3  JavaScriptCore                 0x1848b8a90 JSC::GCThread::waitForNextPhase() + 144
4  JavaScriptCore                 0x1848b8b28 JSC::GCThread::gcThreadMain() + 84
5  JavaScriptCore                 0x18458e634 WTF::threadEntryPoint(void*) + 212
6  JavaScriptCore                 0x18458e544 WTF::wtfThreadEntryPoint(void*) + 24
7  libsystem_pthread.dylib        0x180f9fb28 _pthread_body + 156
8  libsystem_pthread.dylib        0x180f9fa8c _pthread_body + 154
9  libsystem_pthread.dylib        0x180f9d028 thread_start + 4

#16. com.apple.CFSocket.private
0  libsystem_kernel.dylib         0x180ed8368 __select + 8
1  CoreFoundation                 0x1812f3028 __CFSocketManager + 648
2  libsystem_pthread.dylib        0x180f9fb28 _pthread_body + 156
3  libsystem_pthread.dylib        0x180f9fa8c _pthread_body + 154
4  libsystem_pthread.dylib        0x180f9d028 thread_start + 4


来源: stackexchange

问:
How to scroll down a page until all the views appeared?
In my page I have lots of data. The first time page opened i can see only number of data. When I scroll down the page other datas are starting to appear. It is going repeatedly. Problem is I wanna see all datas in my page and take their names but when I use List <WebElement> listItems=driver.findElement(AAA).findElements(BBB);this code, I can only get datas from first page. How can I see the others? (I don't want to use an id or class at the bottom. And scroll till to see it)

答:
You can execute a javascript code like this:</p>

```<code>WebElement element = driver.findElement(By.id("id_of_element"));
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);

//do anything you want with the element
</code>```

ContentLicense: CC BY-SA 3.0

Body:
You can execute a javascript code like this:

WebElement element = driver.findElement(By.id("id_of_element"));
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);

//do anything you want with the element


问:
periodic IOS crash, but I do not see any involvement of my app in crash report
About once a week I'm getting a crash like this one. Maybe I'm wrong, but I do not see any involvement of my app ("WayAndSee"). Does anybody have a hint how to proceed?

Attached the crash report (which is very typically for that kind of crash), I just truncated the trailing list of libraries.

Many thanks in advance ...

```<code>Incident Identifier: 348BDC52-6574-4EED-A6C7-45E79E696875
CrashReporter Key:   f8ac3e1a61b8129920a4ad40aaa56d5536e2ce22
Hardware Model:      iPhone6,2
Process:             WayAndSee [8286]
Path:                /private/var/containers/Bundle/Application/F1542EC3-3708-4B6E-80EA-A2333883359E/WayAndSee.app/WayAndSee
Identifier:          Hobrink.WayAndSee
Version:             2487 (0.3.0)
Code Type:           ARM (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           Hobrink.WayAndSee [2936]

Date/Time:           2017-04-04 14:28:15.3459 +0200
Launch Time:         2017-04-04 13:05:54.5835 +0200
OS Version:          iPhone OS 10.2.1 (14D27)
Report Version:      104

Exception Type:  EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Termination Reason: Namespace SPRINGBOARD, Code 0x8badf00d
Triggered by Thread:  0

Filtered syslog:
None found

Thread 0 Crashed:
0   libsystem_kernel.dylib          0x1cedf84c mach_msg_trap + 20
1   CoreFoundation                  0x1d7082f9 __CFRunLoopServiceMachPort + 137
2   CoreFoundation                  0x1d7065f7 __CFRunLoopRun + 1015
3   CoreFoundation                  0x1d655533 CFRunLoopRunSpecific + 487
4   CoreFoundation                  0x1d655341 CFRunLoopRunInMode + 105
5   GraphicsServices                0x1ee2cbfd GSEventRunModal + 157
6   UIKit                           0x22863e67 -[UIApplication _run] + 575
7   UIKit                           0x2285e591 UIApplicationMain + 151
8   WayAndSee                       0x000ba890 main (AppDelegateV2a.swift:667)
9   libdyld.dylib                   0x1ce1f50b start + 3

Thread 1 name:  com.apple.uikit.eventfetch-thread
Thread 1:
0   libsystem_kernel.dylib          0x1cedf84c mach_msg_trap + 20
1   CoreFoundation                  0x1d7082f9 __CFRunLoopServiceMachPort + 137
2   CoreFoundation                  0x1d7065f7 __CFRunLoopRun + 1015
3.  CoreFoundation                  0x1d655533 CFRunLoopRunSpecific + 487
4   CoreFoundation                  0x1d655341 CFRunLoopRunInMode + 105
5   Foundation                      0x1dfaf88b -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 261
6   Foundation                      0x1dfce631 -[NSRunLoop(NSRunLoop) runUntilDate:] + 87
7   UIKit                           0x2316a2b3 -[UIEventFetcher threadMain] + 129
8   Foundation                      0x1e098b11 __NSThread__start__ + 1161
9   libsystem_pthread.dylib         0x1cfa9a27 _pthread_body + 217
10  libsystem_pthread.dylib         0x1cfa994d _pthread_start + 235
11  libsystem_pthread.dylib         0x1cfa749c thread_start + 8

Thread 2 name:  NetworkLoad
Thread 2:
0   libsystem_kernel.dylib          0x1cedf84c mach_msg_trap + 20
1   CoreFoundation                  0x1d7082f9 __CFRunLoopServiceMachPort + 137
2   CoreFoundation                  0x1d7065f7 __CFRunLoopRun + 1015
3   CoreFoundation                  0x1d655533 CFRunLoopRunSpecific + 487
4   CoreFoundation                  0x1d655341 CFRunLoopRunInMode + 105
5   GeoServices                     0x244775ff _runNetworkThread + 475
6   libsystem_pthread.dylib         0x1cfa9a27 _pthread_body + 217
7   libsystem_pthread.dylib         0x1cfa994d _pthread_start + 235
8   libsystem_pthread.dylib         0x1cfa749c thread_start + 8

Thread 3:
0   libsystem_kernel.dylib          0x1cef5744 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x1cfa7490 start_wqthread + 8

Thread 4:
0   libsystem_pthread.dylib         0x1cfa7488 start_wqthread + 0

Thread 5:
0   libsystem_pthread.dylib         0x1cfa7488 start_wqthread + 0

Thread 6:
0   libsystem_pthread.dylib         0x1cfa7488 start_wqthread + 0

Thread 0 crashed with ARM Thread State (32-bit):
    r0: 0x10004005    r1: 0x07000806      r2: 0x00000000      r3: 0x00000c00
    r4: 0x00002403    r5: 0xffffffff      r6: 0x00000000      r7: 0x0042adb4
    r8: 0x00000c00    r9: 0x00002403     r10: 0x07000806     r11: 0x00000000
    ip: 0xffffffe1    sp: 0x0042ad78      lr: 0x1cedf63f      pc: 0x1cedf84c
  cpsr: 0x60000010

Binary Images:
0xb0000 - 0x177fff WayAndSee armv7  <7506039ae577329ab9868e3122d84f5f> /var/containers/Bundle/Application/F1542EC3-3708-4B6E-80EA-A2333883359E/WayAndSee.app/WayAndSee
0x25c000 - 0x267fff libswiftCoreData.dylib armv7s  <3022e21a184d3e6c93bac1ad7b18be30> /var/containers/Bundle/Application/F1542EC3-3708-4B6E-80EA-A2333883359E/WayAndSee.app/Frameworks/libswiftCoreData.dylib
0x27c000 - 0x28bfff libswiftCoreGraphics.dylib armv7s  <4415e467b6df386591e646e7a2978da6> /var/containers/Bundle/Application/F1542EC3-3708-4B6E-80EA-A2333883359E/WayAndSee.app/Frameworks/libswiftCoreGraphics.dylib
0x2a8000 - 0x2affff libswiftCoreImage.dylib armv7s  <9bbbe5b77fdd3551921ca7ec1a98ae38> /var/containers/Bundle/Application/F1542EC3-3708-4B6E-80EA-A2333883359E/WayAndSee.app/Frameworks/libswiftCoreImage.dylib
0x2c0000 - 0x2ebfff dyld armv7s  <898b6b42ae3b3ffb8de9a96b7071f49d> /usr/lib/dyld
0x42c000 - 0x6abfff libswiftCore.dylib armv7s  <b760608c5d35390099731eedb8821bc0> /var/containers/Bundle/Application/F1542EC3-3708-4B6E-80EA-A2333883359E/WayAndSee.app/Frameworks/libswiftCore.dylib

....
</code>```

答:
as I got several questions about my progress on this issue, I decided to wrote an answer by myself. Maybe this could be helpful for others.

The crash reports has one important line: "Termination Reason: Namespace SPRINGBOARD, Code 0x8badf00d" -> the SPRINGBOARD tried to start the app in background... and "0x8dadf00d" could be read as "ate bad food" (look around here on StackOverflow, numerous explanation for that code)

The root cause of that issue is simply the launchtime. It's too long for a start in background. There is a time limit for background start of about 5 to 7 seconds. Launch in foreground has an allowed time window of about 20 sec.

This time limit includes the time BEFORE main() and AFTER main() until the app its settled and ready to receive the launching event. Each launch of an app in background is caused by a launching event (location, file transfer etc.)

To get an idea how to analyze the time before main() I suggest to watch the video "Optimizing App Startup Time", Session 406, WWDC 2016. They explain in detail what happen BEFORE main and how to analyze and measure it. They describe several environment variables (set in "arguments" section of the scheme) which produce helpful logs.

"main()", yes, I learned it during this examination. Swift allows it to have a main(). It's even a possibility to execute statements outside of a function, class, struct ... There is no real need for that in swift. But as I wanted to measure the launch time after main, I wrote this simple main.swift file to do so.

```<code>//
//  main.swift
//  ...
//
//  Created by Hartwig Hopfenzitz on 31.05.17.
//  Copyright © 2017 Hopfenzitz. All rights reserved.
//

import Foundation
import UIKit

// very first statement after load.. the current time
let WaysStartTime = CFAbsoluteTimeGetCurrent()

// build the parameters for the call to UIApplicationMain()
let argc = CommandLine.argc
let argv = UnsafeMutableRawPointer(CommandLine.unsafeArgv).bindMemory(to: UnsafeMutablePointer<Int8>.self, capacity: Int(CommandLine.argc))

// start the main loop
UIApplicationMain(argc, argv, nil, NSStringFromClass(AppDelegate.self))
</code>```

As you can see: In the very first statement I take the time. With this I can measure the time difference to the time when the app is up and running.

However: If you want to use a main() in your swift project, you have to comment out or delete the statement "@UIApplicationMain" in AppDelegate.swift. This statement "simulates" the main() function, so it would be redundant.

And yes, it is worth to start measure on main(). I did also tests with time measuring starting on "willFinishLaunchingWithOptions:". On my usual test device, an iPhone 5s (real test device, not a simulator), the difference is about 0.4 sec. I'm sure that time depends on the app and how it is structured, so I suggest to measure it from main().

OK, and as always: "if you measure, you are able to manage".

The usual root cause for slow launch times is an overloaded main thread. This main thread is the most important working horse of each app. It burdens the event loop and the UI.

So my first step was to shift as much work as possible away from main threat by using GCD (Grand Central Dispatch). GCD is quite easy to use and gives you a lot of options to fine tune the workload of the several threads. There are several videos on WWDC about GCD, my personal favorite one is the "Building Responsive and Efficient Apps with GCD", Session 718, WWDC 2015.

However, by this I reduced the number of crashes drastically, BUT.... there was still crashes ...

My initial screen is so complex, using a lot of autolayout and autosizing etc.. It simply sometimes took to long to finish the rendering before the time limit crashes the app. If I understand everything right, IOS wants to have the first screen up and running, to consider a successful launch.

Well, the magic words are "the first screen".

I love my Main.storyboard, very nice looking and highly adaptive. So I didn't want to strip it down. Luckily I found this blog http://timdietrich.me/blog/swift-multiple-storyboards/. It describes the steps necessary to work with several storyboards in an swift/xcode project. There are several others to find on the internet, but this one is quite easy to read and understand.

So I created a storyboard called "Start.storyboard". This storyboard is very simple, just a copy of the Launchscreen.storyboard. And I used this as "the first screen".

I created this class for the ViewController of this start screen, which does nothing else than launching my Main.Storyboard.

```<code>//
//  StartViewController.swift
//  ...
//
//  Created by Hartwig Hopfenzitz on 02.06.17.
//  Copyright © 2017 Hopfenzitz. All rights reserved.
//

import UIKit

class StartViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.

        // Create instance of our main storyboard
        let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)

        // Create the instance of main's initial view controller.
        let mainController = mainStoryboard.instantiateViewController(withIdentifier: "WaysViewController") as UIViewController

        // Make sure it will start on the main thread
        DispatchQueue.main.async(execute: {

            // present it .. and never come back
            mainController.modalTransitionStyle = UIModalTransitionStyle.crossDissolve
            mainController.modalPresentationStyle = .fullScreen // Display on top of current UIView

            self.present(mainController, animated: true, completion: nil)
        })
    }
}
</code>```

In Info.plist you will find the key "Main storyboard file base name". This key tells which story board is the one with the initial screen. So in my example you have to change the value from "Main" to "Start", as the new initial storyboard is called "Start.storyboard".

And Voilá: the first screen starts almost immediately and IOS is very happy about the launch time. The user doesn't recognize it.

OK that's how I got rid of this crashes... maybe it will help others...

Happy coding ;-)

Body:
About once a week I'm getting a crash like this one. Maybe I'm wrong, but I do not see any involvement of my app ("WayAndSee"). Does anybody have a hint how to proceed?

Attached the crash report (which is very typically for that kind of crash), I just truncated the trailing list of libraries.

Many thanks in advance ...

Incident Identifier: 348BDC52-6574-4EED-A6C7-45E79E696875
CrashReporter Key:   f8ac3e1a61b8129920a4ad40aaa56d5536e2ce22
Hardware Model:      iPhone6,2
Process:             WayAndSee [8286]
Path:                /private/var/containers/Bundle/Application/F1542EC3-3708-4B6E-80EA-A2333883359E/WayAndSee.app/WayAndSee
Identifier:          Hobrink.WayAndSee
Version:             2487 (0.3.0)
Code Type:           ARM (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           Hobrink.WayAndSee [2936]

Date/Time:           2017-04-04 14:28:15.3459 +0200
Launch Time:         2017-04-04 13:05:54.5835 +0200
OS Version:          iPhone OS 10.2.1 (14D27)
Report Version:      104

Exception Type:  EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Termination Reason: Namespace SPRINGBOARD, Code 0x8badf00d
Triggered by Thread:  0

Filtered syslog:
None found

Thread 0 Crashed:
0   libsystem_kernel.dylib          0x1cedf84c mach_msg_trap + 20
1   CoreFoundation                  0x1d7082f9 __CFRunLoopServiceMachPort + 137
2   CoreFoundation                  0x1d7065f7 __CFRunLoopRun + 1015
3   CoreFoundation                  0x1d655533 CFRunLoopRunSpecific + 487
4   CoreFoundation                  0x1d655341 CFRunLoopRunInMode + 105
5   GraphicsServices                0x1ee2cbfd GSEventRunModal + 157
6   UIKit                           0x22863e67 -[UIApplication _run] + 575
7   UIKit                           0x2285e591 UIApplicationMain + 151
8   WayAndSee                       0x000ba890 main (AppDelegateV2a.swift:667)
9   libdyld.dylib                   0x1ce1f50b start + 3

Thread 1 name:  com.apple.uikit.eventfetch-thread
Thread 1:
0   libsystem_kernel.dylib          0x1cedf84c mach_msg_trap + 20
1   CoreFoundation                  0x1d7082f9 __CFRunLoopServiceMachPort + 137
2   CoreFoundation                  0x1d7065f7 __CFRunLoopRun + 1015
3.  CoreFoundation                  0x1d655533 CFRunLoopRunSpecific + 487
4   CoreFoundation                  0x1d655341 CFRunLoopRunInMode + 105
5   Foundation                      0x1dfaf88b -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 261
6   Foundation                      0x1dfce631 -[NSRunLoop(NSRunLoop) runUntilDate:] + 87
7   UIKit                           0x2316a2b3 -[UIEventFetcher threadMain] + 129
8   Foundation                      0x1e098b11 __NSThread__start__ + 1161
9   libsystem_pthread.dylib         0x1cfa9a27 _pthread_body + 217
10  libsystem_pthread.dylib         0x1cfa994d _pthread_start + 235
11  libsystem_pthread.dylib         0x1cfa749c thread_start + 8

Thread 2 name:  NetworkLoad
Thread 2:
0   libsystem_kernel.dylib          0x1cedf84c mach_msg_trap + 20
1   CoreFoundation                  0x1d7082f9 __CFRunLoopServiceMachPort + 137
2   CoreFoundation                  0x1d7065f7 __CFRunLoopRun + 1015
3   CoreFoundation                  0x1d655533 CFRunLoopRunSpecific + 487
4   CoreFoundation                  0x1d655341 CFRunLoopRunInMode + 105
5   GeoServices                     0x244775ff _runNetworkThread + 475
6   libsystem_pthread.dylib         0x1cfa9a27 _pthread_body + 217
7   libsystem_pthread.dylib         0x1cfa994d _pthread_start + 235
8   libsystem_pthread.dylib         0x1cfa749c thread_start + 8

Thread 3:
0   libsystem_kernel.dylib          0x1cef5744 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x1cfa7490 start_wqthread + 8

Thread 4:
0   libsystem_pthread.dylib         0x1cfa7488 start_wqthread + 0

Thread 5:
0   libsystem_pthread.dylib         0x1cfa7488 start_wqthread + 0

Thread 6:
0   libsystem_pthread.dylib         0x1cfa7488 start_wqthread + 0

Thread 0 crashed with ARM Thread State (32-bit):
    r0: 0x10004005    r1: 0x07000806      r2: 0x00000000      r3: 0x00000c00
    r4: 0x00002403    r5: 0xffffffff      r6: 0x00000000      r7: 0x0042adb4
    r8: 0x00000c00    r9: 0x00002403     r10: 0x07000806     r11: 0x00000000
    ip: 0xffffffe1    sp: 0x0042ad78      lr: 0x1cedf63f      pc: 0x1cedf84c
  cpsr: 0x60000010

Binary Images:
0xb0000 - 0x177fff WayAndSee armv7  <7506039ae577329ab9868e3122d84f5f> /var/containers/Bundle/Application/F1542EC3-3708-4B6E-80EA-A2333883359E/WayAndSee.app/WayAndSee
0x25c000 - 0x267fff libswiftCoreData.dylib armv7s  <3022e21a184d3e6c93bac1ad7b18be30> /var/containers/Bundle/Application/F1542EC3-3708-4B6E-80EA-A2333883359E/WayAndSee.app/Frameworks/libswiftCoreData.dylib
0x27c000 - 0x28bfff libswiftCoreGraphics.dylib armv7s  <4415e467b6df386591e646e7a2978da6> /var/containers/Bundle/Application/F1542EC3-3708-4B6E-80EA-A2333883359E/WayAndSee.app/Frameworks/libswiftCoreGraphics.dylib
0x2a8000 - 0x2affff libswiftCoreImage.dylib armv7s  <9bbbe5b77fdd3551921ca7ec1a98ae38> /var/containers/Bundle/Application/F1542EC3-3708-4B6E-80EA-A2333883359E/WayAndSee.app/Frameworks/libswiftCoreImage.dylib
0x2c0000 - 0x2ebfff dyld armv7s  <898b6b42ae3b3ffb8de9a96b7071f49d> /usr/lib/dyld
0x42c000 - 0x6abfff libswiftCore.dylib armv7s  <b760608c5d35390099731eedb8821bc0> /var/containers/Bundle/Application/F1542EC3-3708-4B6E-80EA-A2333883359E/WayAndSee.app/Frameworks/libswiftCore.dylib

....

Body:
as I got several questions about my progress on this issue, I decided to wrote an answer by myself. Maybe this could be helpful for others.

The crash reports has one important line: "Termination Reason: Namespace SPRINGBOARD, Code 0x8badf00d" -> the SPRINGBOARD tried to start the app in background... and "0x8dadf00d" could be read as "ate bad food" (look around here on StackOverflow, numerous explanation for that code)

The root cause of that issue is simply the launchtime. It's too long for a start in background. There is a time limit for background start of about 5 to 7 seconds. Launch in foreground has an allowed time window of about 20 sec.

This time limit includes the time BEFORE main() and AFTER main() until the app its settled and ready to receive the launching event. Each launch of an app in background is caused by a launching event (location, file transfer etc.)

To get an idea how to analyze the time before main() I suggest to watch the video "Optimizing App Startup Time", Session 406, WWDC 2016. They explain in detail what happen BEFORE main and how to analyze and measure it. They describe several environment variables (set in "arguments" section of the scheme) which produce helpful logs.

"main()", yes, I learned it during this examination. Swift allows it to have a main(). It's even a possibility to execute statements outside of a function, class, struct ... There is no real need for that in swift. But as I wanted to measure the launch time after main, I wrote this simple main.swift file to do so.

//
//  main.swift
//  ...
//
//  Created by Hartwig Hopfenzitz on 31.05.17.
//  Copyright © 2017 Hopfenzitz. All rights reserved.
//

import Foundation
import UIKit

// very first statement after load.. the current time
let WaysStartTime = CFAbsoluteTimeGetCurrent()

// build the parameters for the call to UIApplicationMain()
let argc = CommandLine.argc
let argv = UnsafeMutableRawPointer(CommandLine.unsafeArgv).bindMemory(to: UnsafeMutablePointer<Int8>.self, capacity: Int(CommandLine.argc))

// start the main loop
UIApplicationMain(argc, argv, nil, NSStringFromClass(AppDelegate.self))

As you can see: In the very first statement I take the time. With this I can measure the time difference to the time when the app is up and running.

However: If you want to use a main() in your swift project, you have to comment out or delete the statement "@UIApplicationMain" in AppDelegate.swift. This statement "simulates" the main() function, so it would be redundant.

And yes, it is worth to start measure on main(). I did also tests with time measuring starting on "willFinishLaunchingWithOptions:". On my usual test device, an iPhone 5s (real test device, not a simulator), the difference is about 0.4 sec. I'm sure that time depends on the app and how it is structured, so I suggest to measure it from main().

OK, and as always: "if you measure, you are able to manage".

The usual root cause for slow launch times is an overloaded main thread. This main thread is the most important working horse of each app. It burdens the event loop and the UI.

So my first step was to shift as much work as possible away from main threat by using GCD (Grand Central Dispatch). GCD is quite easy to use and gives you a lot of options to fine tune the workload of the several threads. There are several videos on WWDC about GCD, my personal favorite one is the "Building Responsive and Efficient Apps with GCD", Session 718, WWDC 2015.

However, by this I reduced the number of crashes drastically, BUT.... there was still crashes ...

My initial screen is so complex, using a lot of autolayout and autosizing etc.. It simply sometimes took to long to finish the rendering before the time limit crashes the app. If I understand everything right, IOS wants to have the first screen up and running, to consider a successful launch.

Well, the magic words are "the first screen".

I love my Main.storyboard, very nice looking and highly adaptive. So I didn't want to strip it down. Luckily I found this blog http://timdietrich.me/blog/swift-multiple-storyboards/. It describes the steps necessary to work with several storyboards in an swift/xcode project. There are several others to find on the internet, but this one is quite easy to read and understand.

So I created a storyboard called "Start.storyboard". This storyboard is very simple, just a copy of the Launchscreen.storyboard. And I used this as "the first screen".

I created this class for the ViewController of this start screen, which does nothing else than launching my Main.Storyboard.

//
//  StartViewController.swift
//  ...
//
//  Created by Hartwig Hopfenzitz on 02.06.17.
//  Copyright © 2017 Hopfenzitz. All rights reserved.
//

import UIKit

class StartViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.

        // Create instance of our main storyboard
        let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)

        // Create the instance of main's initial view controller.
        let mainController = mainStoryboard.instantiateViewController(withIdentifier: "WaysViewController") as UIViewController

        // Make sure it will start on the main thread
        DispatchQueue.main.async(execute: {

            // present it .. and never come back
            mainController.modalTransitionStyle = UIModalTransitionStyle.crossDissolve
            mainController.modalPresentationStyle = .fullScreen // Display on top of current UIView

            self.present(mainController, animated: true, completion: nil)
        })
    }
}

In Info.plist you will find the key "Main storyboard file base name". This key tells which story board is the one with the initial screen. So in my example you have to change the value from "Main" to "Start", as the new initial storyboard is called "Start.storyboard".

And Voilá: the first screen starts almost immediately and IOS is very happy about the launch time. The user doesn't recognize it.

OK that's how I got rid of this crashes... maybe it will help others...

Happy coding ;-)


问:
Want to add a timer to GlassFish Server, don't know where to start
I'm trying to implement Java EE websockets with a Glassfish server, and I've got the basics down already.

As for my current project, I want to implement server "ticks" like in a game, that update the server every few milliseconds so that all sessions connected to the server see the same thing.

However, I don't know where to start to make this work with Glassfish. I know that I create a server from scratch and implement a timer method, but I'd rather save myself some work here if possible.

Simply put, is it easy to implement a timer/tick mechanism in the glassfish server (assuming it is running)?

For example, I want to make the server periodically send the word "hello" to a client HTML page once they are connected via websocket.

答:
Short Version

We solved it with three classes:

Scheduler class: the clock which send an Event

Websocket endpoint: the basic websocket session handler

Websocket session handler: the conductor which catches the Event and manages all the websocket sessions

Long version with code

Now for the code, 1) is the one Mike mentioned in comment: a classic Scheduler which fires some event. This class is basically a clock which knocks whoever is listening to its event. We have a EAR=EJB+WAR project. Our timer is in the EJB module but if you have a single WAR, you can put it there.

```<code>// some import
import javax.enterprise.event.Event;

@Singleton
@Startup
public class TimerBean {

    @Inject
    private Event<TickEvent> tickEvent;

    @Schedule(hour = "*", minute = "*", second = "*/5")
    public void printSchedule() {
        tickEvent.fire(new TickEvent(/*...your initialization...*/));
    }

    public class TickEvent{
        // we have some info here but you can
        // leave it empty.
    }

}
</code>```

For the 2) websocket endpoint, this is a very academic endpoint. Don't forget that one connection = one endpoint instance. You can find all opened sessions from a given session with session.getOpenedSessions() but I'll explain why I use a handler in the next part.

```<code>// some import
import javax.websocket.OnClose;
import javax.websocket.OnError;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;

@ServerEndPoint(value = "/myEndPointPath")
public class TickEndPoint{

    @Inject
    private TickSessionHandler sessionHandler;

    @OnOpen
    public void onOpen(Session session){
        sessionHandler.addSession(session);
    }

    @OnClose
    public void onClose(Session session, CloseReason reason){
         sessionHandler.removeSession(session);
    }

}
</code>```

And now the keystone: the session handler. The session handler is an ApplicationScoped bean, so it's always available. The reason I used it:

When TickEvent is fired, you don't know if a TickEndPoint instance exists or not so the event catching may raise some stupid errors. We fixed it with @Observes(notifyObserver = Reception.IF_EXISTS) but we met other EJB problems which I'll detail in 2.

For a reason I haven't identified yet, when I used @Observes in my @ServerEndPoint, all my @EJB injection failed so I switched @EJB injection to @Inject. But as the ApplicationScoped is a CDI bean, @EJB and @Observes work very well together in the session handler class. We didn't really need the @EJB annotation by itself but for design consistency with other bean, we wanted all our EJB to be annotated with @EJB.

Monitoring: you can do monitoring such as how many "hello" you sent at time T, giving you a time vs number of connected sessions graph.

Plus, in our particular situation, we have some point that you may meet later.

We need to select a particular subset of SESSIONS, not all of them. Having a static Set in the @ServerEndPoint led to some-stuff-which-turned-me-into-Hulk behavior especially when you have EJB dependencies. In an example of a game, let's you have capture the flag scenario with blue team and red team. If red team capture the flag, you need to send "Oops, we lost the flag" to the blue team and "Yeah we got it" to the red team.

Monitoring: apart from connection time and stuff, we need info such as "last activity time" and stuff. To properly put it in a JSF datatable, a list/set in a CDI bean is the best option

I encountered some tutorial/detail where the @ServerEndPoint is annotated @ApplicationScoped. By design (one server endpoint = one websocket connection), I don't feel comfortable with it so I refused to implement this solution

```<code>@Named
@ApplicationScoped
public class TickSessionHandler{

    // There is no need to have a static Set, worst,
    // containers don't like it
    public Set<Session> SESSIONS;

    // let's initialize the set
    public TickSessionHandler{
        this.SESSIONS = new HashSet<>();
    }

    // ---------- sessions management
    public void addSession(Session session){
        this.SESSIONS.add(session);
    }

    public void removeSession(Sesssion session){
        this.SESSIONS.remove(session);
    }

    // ---------- Listen to the timer
    public void onTick(@Observes TickEvent event){

        // if required, get the event attribute
        // and proceed

        // your request:
        this.SESSIONS.forEach(session -> {
            session.getBasicRemote().sendText("hello");
        });
    }

}
</code>```

Hope this help. The explanation seems long but the core implementation is actually very light. AFAIK, there is no shortcut for such requirement.

Body:
Short Version

We solved it with three classes:

Scheduler class: the clock which send an Event

Websocket endpoint: the basic websocket session handler

Websocket session handler: the conductor which catches the Event and manages all the websocket sessions

Long version with code

Now for the code, 1) is the one Mike mentioned in comment: a classic Scheduler which fires some event. This class is basically a clock which knocks whoever is listening to its event. We have a EAR=EJB+WAR project. Our timer is in the EJB module but if you have a single WAR, you can put it there.

// some import
import javax.enterprise.event.Event;

@Singleton
@Startup
public class TimerBean {

    @Inject
    private Event<TickEvent> tickEvent;

    @Schedule(hour = "*", minute = "*", second = "*/5")
    public void printSchedule() {
        tickEvent.fire(new TickEvent(/*...your initialization...*/));
    }

    public class TickEvent{
        // we have some info here but you can
        // leave it empty.
    }

}

For the 2) websocket endpoint, this is a very academic endpoint. Don't forget that one connection = one endpoint instance. You can find all opened sessions from a given session with session.getOpenedSessions() but I'll explain why I use a handler in the next part.

// some import
import javax.websocket.OnClose;
import javax.websocket.OnError;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;

@ServerEndPoint(value = "/myEndPointPath")
public class TickEndPoint{

    @Inject
    private TickSessionHandler sessionHandler;

    @OnOpen
    public void onOpen(Session session){
        sessionHandler.addSession(session);
    }

    @OnClose
    public void onClose(Session session, CloseReason reason){
         sessionHandler.removeSession(session);
    }

}

And now the keystone: the session handler. The session handler is an ApplicationScoped bean, so it's always available. The reason I used it:

When TickEvent is fired, you don't know if a TickEndPoint instance exists or not so the event catching may raise some stupid errors. We fixed it with @Observes(notifyObserver = Reception.IF_EXISTS) but we met other EJB problems which I'll detail in 2.

For a reason I haven't identified yet, when I used @Observes in my @ServerEndPoint, all my @EJB injection failed so I switched @EJB injection to @Inject. But as the ApplicationScoped is a CDI bean, @EJB and @Observes work very well together in the session handler class. We didn't really need the @EJB annotation by itself but for design consistency with other bean, we wanted all our EJB to be annotated with @EJB.

Monitoring: you can do monitoring such as how many "hello" you sent at time T, giving you a time vs number of connected sessions graph.

Plus, in our particular situation, we have some point that you may meet later.

We need to select a particular subset of SESSIONS, not all of them. Having a static Set in the @ServerEndPoint led to some-stuff-which-turned-me-into-Hulk behavior especially when you have EJB dependencies. In an example of a game, let's you have capture the flag scenario with blue team and red team. If red team capture the flag, you need to send "Oops, we lost the flag" to the blue team and "Yeah we got it" to the red team.

Monitoring: apart from connection time and stuff, we need info such as "last activity time" and stuff. To properly put it in a JSF datatable, a list/set in a CDI bean is the best option

I encountered some tutorial/detail where the @ServerEndPoint is annotated @ApplicationScoped. By design (one server endpoint = one websocket connection), I don't feel comfortable with it so I refused to implement this solution

@Named
@ApplicationScoped
public class TickSessionHandler{

    // There is no need to have a static Set, worst,
    // containers don't like it
    public Set<Session> SESSIONS;

    // let's initialize the set
    public TickSessionHandler{
        this.SESSIONS = new HashSet<>();
    }

    // ---------- sessions management
    public void addSession(Session session){
        this.SESSIONS.add(session);
    }

    public void removeSession(Sesssion session){
        this.SESSIONS.remove(session);
    }

    // ---------- Listen to the timer
    public void onTick(@Observes TickEvent event){

        // if required, get the event attribute
        // and proceed

        // your request:
        this.SESSIONS.forEach(session -> {
            session.getBasicRemote().sendText("hello");
        });
    }

}

Hope this help. The explanation seems long but the core implementation is actually very light. AFAIK, there is no shortcut for such requirement.


问:
jQuery Accordion Last section to diplay by defautl?
How can i make last section as active in accordion by default?

```<code> $("#accordion").accordion("active", last)
</code>```

as I will have a Dynamic set of sections in the accordion.

By default i wan the last section to be active

How can i do that?

答: $( "#accordion" ).accordion( "option", "active", -1 ); works fine. </p>

Body:
How can i make last section as active in accordion by default?

 $("#accordion").accordion("active", last)

as I will have a Dynamic set of sections in the accordion.

By default i wan the last section to be active

How can i do that?


问:
Maps not working in IOS 4.2
I made one app in IOS4.0 which is working fine. but now i upgraded to IOS 4.2, and now the maps annotations are not showing. But its working absolutely fine on IOS 4.0.

the breakpoint is not coming to the third line of code given below i.e. "MKPinAnnotationView *view;".

```<code>-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
{
    if ([annotation isKindOfClass:[MKUserLocation class]])
        return nil;

    MKPinAnnotationView *view;
</code>```

Please help.
Thanks in advance.

答:
Why you are using these lines of code in Annotation

if ([annotation isKindOfClass:[MKUserLocation class]])

```<code>    return nil;
</code>```

Your breakpoint is not coming to the third line just because it simply return by nil

ContentLicense: CC BY-SA 2.5

Title: Maps not working in IOS 4.2

Body:
I made one app in IOS4.0 which is working fine. but now i upgraded to IOS 4.2, and now the maps annotations are not showing. But its working absolutely fine on IOS 4.0.

the breakpoint is not coming to the third line of code given below i.e. "MKPinAnnotationView *view;".

-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
{
    if ([annotation isKindOfClass:[MKUserLocation class]])
        return nil;

    MKPinAnnotationView *view;

Please help.
Thanks in advance.

Body:
Why you are using these lines of code in Annotation

if ([annotation isKindOfClass:[MKUserLocation class]])

    return nil;

Your breakpoint is not coming to the third line just because it simply return by nil


问:
Python pandas dataframe and excel: Add cell background color
Currently I save my dataframe like this

```<code>writer = ExcelWriter('test.xlsx')
test_df.to_excel(writer,'Sheet1')
writer.save()
</code>```

And resulted excel file looks like this

```<code>cus  1  abc 2 jbd 3 lkl ...
1   col  v  v  v  v  v ...
2    v   v col v  v  v ...
3    v   v  v  v col v ...
</code>```

What I need is that, when cus value == header value, that cell should have a green background. In example above, all cells with value 'col' should be set green background. How can I do this?

答:
You can use the StyleFrame library to achieve this.

To install

```<code>pip install styleframe
</code>```

The documentation of this library can be found here.

Try the following code to check whether it works to serve your purpose.

```<code>import pandas as pd
from StyleFrame import StyleFrame, Styler

df = pd.DataFrame(" Your Dataframe ")

sf = StyleFrame(df)
style = Styler(bg_color='green')
for col_name in df.columns:
    sf.apply_style_by_indexes(sf.loc[sf['col_name']== col_name ], cols_to_style=col_name,
                          styler_obj=style)
sf.to_excel('test.xlsx').save()
</code>```

Cheers!

Body:
Currently I save my dataframe like this

writer = ExcelWriter('test.xlsx')
test_df.to_excel(writer,'Sheet1')
writer.save()

And resulted excel file looks like this

cus  1  abc 2 jbd 3 lkl ...
1   col  v  v  v  v  v ...
2    v   v col v  v  v ...
3    v   v  v  v col v ...

What I need is that, when cus value == header value, that cell should have a green background. In example above, all cells with value 'col' should be set green background. How can I do this?

Body:
You can use the StyleFrame library to achieve this.

To install

pip install styleframe

The documentation of this library can be found here.

Try the following code to check whether it works to serve your purpose.

import pandas as pd
from StyleFrame import StyleFrame, Styler

df = pd.DataFrame(" Your Dataframe ")

sf = StyleFrame(df)
style = Styler(bg_color='green')
for col_name in df.columns:
    sf.apply_style_by_indexes(sf.loc[sf['col_name']== col_name ], cols_to_style=col_name,
                          styler_obj=style)
sf.to_excel('test.xlsx').save()

Cheers!


问:
ansible reading variable from json file
i am new to ansible world. trying to providing all variable from json file, but its not accepting. it shows and error variable undefined

below is my json file

```<code>{
   "Tomcat":{
       "SHPN":"8905",
       "HTPN":"8980",
       "SSPN":"8943",
       "AJPN":"8909",
       "Server":"test.example.com",
       "JENKINS_HOME":"/apps/tech/jenkins/jenkins-configuration",
       "PName":"Tomcat-Installation",
       "IName":"ansible_test",
       "IUID":"jbosscfg",
       "IGID":"staff",
       "IDEPT":"tech",
       "IRECPT":"test@example.com"
   }
}
</code>```

below is my playbook

```<code>---
-
  gather_facts: false
  hosts: "{{Server}}"
  tasks:
    -
      ignore_errors: true
      name: "find no of Tomcat Instance available on the Server"
      copy:
        src: "{{ JENKINS_HOME }}/workspace/{{ PName }}/instance/"
        dest: /apps/tech/{{IName}}
        group: "{{IGID}}"
        owner: "{{IUID}}"
        mode: 0755
    -
      replace: "dest='/apps/tech/{{IName}}/scripts/set_env.sh' regexp='<DEPARTMENT NAME>' replace='{{IDEPT}}'"
    -
      replace: "dest='/apps/tech/{{IName}}/scripts/set_env.sh' regexp='<RECIPIENT>' replace='{{IRECPT}}'"
    -
      replace: "dest='/apps/tech/{{IName}}/scripts/set_env.sh' regexp='<TOMCAT INSTANCE NAME>' replace='{{IName}}'"
    -
      replace: "dest='/apps/tech/{{IName}}/scripts/set_env.sh' regexp='<USER ID>' replace='{{IUID}}'"
    -
      name: "Ansible Template Example"
      template:
        src: tomcat_server.j2
        dest: /apps/tech/{{IName}}/conf/server.xml
        mode: 0777
</code>```

i am below while executing the ansible playbook - error says variable undefined

```<code>test.example.com:~/final:$ ansible-playbook configure-tomcat-instance.yml --extra-vars "@test.json"
ERROR! the field 'hosts' has an invalid value, which appears to include a variable that is undefined. The error was: 'Server' is undefined

The error appears to have been in '/home/jbosscfg/final/configure-tomcat-instance.yml': line 3, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

-
  gather_facts: false
  ^ here
</code>```

答:
You refer variables as if they are at the top level, whereas they are under Tomcat key.

Use hosts: "{{Tomcat.Server}}" or reformat your json file to eliminate Tomcat level.

Title: ansible reading variable from json file

Body:
i am new to ansible world. trying to providing all variable from json file, but its not accepting. it shows and error variable undefined

below is my json file

{
   "Tomcat":{
       "SHPN":"8905",
       "HTPN":"8980",
       "SSPN":"8943",
       "AJPN":"8909",
       "Server":"test.example.com",
       "JENKINS_HOME":"/apps/tech/jenkins/jenkins-configuration",
       "PName":"Tomcat-Installation",
       "IName":"ansible_test",
       "IUID":"jbosscfg",
       "IGID":"staff",
       "IDEPT":"tech",
       "IRECPT":"test@example.com"
   }
}

below is my playbook

---
-
  gather_facts: false
  hosts: "{{Server}}"
  tasks:
    -
      ignore_errors: true
      name: "find no of Tomcat Instance available on the Server"
      copy:
        src: "{{ JENKINS_HOME }}/workspace/{{ PName }}/instance/"
        dest: /apps/tech/{{IName}}
        group: "{{IGID}}"
        owner: "{{IUID}}"
        mode: 0755
    -
      replace: "dest='/apps/tech/{{IName}}/scripts/set_env.sh' regexp='<DEPARTMENT NAME>' replace='{{IDEPT}}'"
    -
      replace: "dest='/apps/tech/{{IName}}/scripts/set_env.sh' regexp='<RECIPIENT>' replace='{{IRECPT}}'"
    -
      replace: "dest='/apps/tech/{{IName}}/scripts/set_env.sh' regexp='<TOMCAT INSTANCE NAME>' replace='{{IName}}'"
    -
      replace: "dest='/apps/tech/{{IName}}/scripts/set_env.sh' regexp='<USER ID>' replace='{{IUID}}'"
    -
      name: "Ansible Template Example"
      template:
        src: tomcat_server.j2
        dest: /apps/tech/{{IName}}/conf/server.xml
        mode: 0777

i am below while executing the ansible playbook - error says variable undefined

test.example.com:~/final:$ ansible-playbook configure-tomcat-instance.yml --extra-vars "@test.json"
ERROR! the field 'hosts' has an invalid value, which appears to include a variable that is undefined. The error was: 'Server' is undefined

The error appears to have been in '/home/jbosscfg/final/configure-tomcat-instance.yml': line 3, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

-
  gather_facts: false
  ^ here


问:
Cannot add property, object is not extensible when binding props in React component
For some reason when I try to bind a function to a prop in my React component, it is coming up with

TypeError: Can't add property onSearch, object is not extensible.

I am not too familiar with what this means or why it is appearing, I think it may be to do with the es6 bindings which I am still finding my way around on.

Here are the two most relevant components.

Searchbox

```<code>import React from 'react';

import SearchForm from 'SearchForm';
import searchDisplay from 'searchDisplay';
import googleRequests from 'googleRequests';

class SearchBox extends React.Component {
constructor() {
    super();
    this.state = {
        searchResults: []
    }
    this.handleSearch = this.handleSearch.bind(this);

}
handleSearch(searchTerm) {
    googleRequests.search(searchTerm).then((response) => {
        console.log(response.items);
        this.extrapolateResults(response.items);
    }), ((error) =>{
        console.log(error)
    });
}
//pull relevant data out of api call
extrapolateResults(arr) {
    function Book(objInArr) {
        this.link = objInArr.selfLink;
        this.bookTitle = objInArr.volumeInfo.title;
        this.author = objInArr.volumeInfo.authors;
        this.bookDescription = objInArr.volumeInfo.description;
        this.thumbnail = function() {
            if (objInArr.volumeInfo.hasOwnProperty('imageLinks')){
            return objInArr.volumeInfo.imageLinks.smallThumbnail
        }
        else {
            return "No Thumbnail Available";
        }
    };
        this.thumbnailPic = this.thumbnail();
}
//push extrapolated data into array
var finalRes = [];
var initRes = arr;
    initRes.forEach(function (objInArr) {
        var obj = new Book(objInArr);
        finalRes.push(obj);
    })
this.setState({
    searchResults: finalRes
})
console.log(finalRes, this.state.searchResults)

}

render() {
    var res = this.state.searchResults;

    function renderResults() {
        if (res.length !== 0) {
            return (<SearchDisplay content={res} />)
        }
        else {
            return;
        }
    }

    var style = {
        border: '1px solid black',
        height: '80%',
        width: '83%'
    }
    return (
        <div style={style}>
            <SearchForm onSearch={this.handleSearch}> </SearchForm>
        </div>)
}
};

export default SearchBox;
</code>```

Searchform

```<code>import React from 'react';

class SearchForm extends React.Component {
constructor(props) {
    super(props);
    this.onFormSubmit = this.onFormSubmit.bind(this);
    this.props.onSearch = props;
}
onFormSubmit(e) {
    e.preventDefault();
    var searchTerm = this.refs.searchTerm.value;
    if (searchTerm.length > 0) {
        this.refs.searchTerm.value = '';
        this.props.onSearch(searchTerm);
    }
}

render() {
    var style = {
        border: '1px solid black',
        float: 'left',
        height: '100%',
        width: '30%'
    }

    return(
        <div style={style} className="container">
            <form onSubmit={this.onFormSubmit}>
                <input type="text" placeholder="search name here" ref="searchTerm"/>
                <input type="submit" className="button" value="Get Book"/>
            </form>
        </div>
        );
}
};

export default SearchForm;
</code>```

I have a feeling I am missing something very simple but after googling this issue for a while I still can't figure out what it is...

答: remove this.props.onSearch = props;... not sure what you wanted to do there on that line

Body:
For some reason when I try to bind a function to a prop in my React component, it is coming up with

TypeError: Can't add property onSearch, object is not extensible.

I am not too familiar with what this means or why it is appearing, I think it may be to do with the es6 bindings which I am still finding my way around on.

Here are the two most relevant components.

Searchbox

import React from 'react';

import SearchForm from 'SearchForm';
import searchDisplay from 'searchDisplay';
import googleRequests from 'googleRequests';

class SearchBox extends React.Component {
constructor() {
    super();
    this.state = {
        searchResults: []
    }
    this.handleSearch = this.handleSearch.bind(this);

}
handleSearch(searchTerm) {
    googleRequests.search(searchTerm).then((response) => {
        console.log(response.items);
        this.extrapolateResults(response.items);
    }), ((error) =>{
        console.log(error)
    });
}
//pull relevant data out of api call
extrapolateResults(arr) {
    function Book(objInArr) {
        this.link = objInArr.selfLink;
        this.bookTitle = objInArr.volumeInfo.title;
        this.author = objInArr.volumeInfo.authors;
        this.bookDescription = objInArr.volumeInfo.description;
        this.thumbnail = function() {
            if (objInArr.volumeInfo.hasOwnProperty('imageLinks')){
            return objInArr.volumeInfo.imageLinks.smallThumbnail
        }
        else {
            return "No Thumbnail Available";
        }
    };
        this.thumbnailPic = this.thumbnail();
}
//push extrapolated data into array
var finalRes = [];
var initRes = arr;
    initRes.forEach(function (objInArr) {
        var obj = new Book(objInArr);
        finalRes.push(obj);
    })
this.setState({
    searchResults: finalRes
})
console.log(finalRes, this.state.searchResults)

}

render() {
    var res = this.state.searchResults;

    function renderResults() {
        if (res.length !== 0) {
            return (<SearchDisplay content={res} />)
        }
        else {
            return;
        }
    }

    var style = {
        border: '1px solid black',
        height: '80%',
        width: '83%'
    }
    return (

            <SearchForm onSearch={this.handleSearch}> </SearchForm>

)
}
};

export default SearchBox;

Searchform

import React from 'react';

class SearchForm extends React.Component {
constructor(props) {
    super(props);
    this.onFormSubmit = this.onFormSubmit.bind(this);
    this.props.onSearch = props;
}
onFormSubmit(e) {
    e.preventDefault();
    var searchTerm = this.refs.searchTerm.value;
    if (searchTerm.length > 0) {
        this.refs.searchTerm.value = '';
        this.props.onSearch(searchTerm);
    }
}

render() {
    var style = {
        border: '1px solid black',
        float: 'left',
        height: '100%',
        width: '30%'
    }

    return(

            <form onSubmit={this.onFormSubmit}>
                <input type="text" placeholder="search name here" ref="searchTerm"/>
                <input type="submit" className="button" value="Get Book"/>
            </form>

        );
}
};

export default SearchForm;

I have a feeling I am missing something very simple but after googling this issue for a while I still can't figure out what it is...


问:
Get container children size, on resize Angular2
I have some code that gets the heights of the child divs of a container div,

Adds the heights to an array, gets the max number of the array (i.e the tallest div) then loops through the divs and sets the heights to the tallest div (i.e makes them equal height)

When the view loads it works very well, however on window resize the height array only updates when the children divs heights are larger than before, but not smaller

i.e. when the page loads the height of children divs = 600px;

I resize the window to make it smaller the height remains 600px and the spaces between the divs increases

When I resize the window to make it larger the heights updates

```<code>public setHeight(){

  this.divHeights = []
  let maxHeight:number;

  let divChildren = this.parentDiv.nativeElement.children
    for (let i = 0; i < divChildren.length; i++){
      let divHeights = divChildren[i].clientHeight
      this.divHeights.push(divHeights);
    }
    maxHeight = Math.max( ...this.divHeights )

    for (let i = 0; i < divChildren.length; i++){
    this.renderer.setStyle(divChildren[i], 'min-height', maxHeight+"px")
    }
}
</code>```

I was wondering if anyone has come across this behaviour before

答:
For anyone getting issues with equal height divs;

What I ended up doing was updating bootstrap in the project to 4, this version handles this issue perfectly

Body:
I have some code that gets the heights of the child divs of a container div,

Adds the heights to an array, gets the max number of the array (i.e the tallest div) then loops through the divs and sets the heights to the tallest div (i.e makes them equal height)

When the view loads it works very well, however on window resize the height array only updates when the children divs heights are larger than before, but not smaller

i.e. when the page loads the height of children divs = 600px;

I resize the window to make it smaller the height remains 600px and the spaces between the divs increases

When I resize the window to make it larger the heights updates

public setHeight(){

  this.divHeights = []
  let maxHeight:number;

  let divChildren = this.parentDiv.nativeElement.children
    for (let i = 0; i < divChildren.length; i++){
      let divHeights = divChildren[i].clientHeight
      this.divHeights.push(divHeights);
    }
    maxHeight = Math.max( ...this.divHeights )

    for (let i = 0; i < divChildren.length; i++){
    this.renderer.setStyle(divChildren[i], 'min-height', maxHeight+"px")
    }
}

I was wondering if anyone has come across this behaviour before


问:
Launching app in landscape orientation causes rotation on launch
I have implemented shouldAutorotateToInterfaceOrientation and everything works fine in terms or orientation changes in my app once it is running. However I don't like the behavior of my app when it is fist launched.

When I launch my app in portrait orientation, it opens as expected, however when I launch my app in landscape orientation, I see everything load in portrait orientation (including the status bar), then I see an animation of my screen rotating to landscape. That animation is fine, but I don't want it to be displayed at launch.

When I look at most other apps, they seem to detect the orientation as they launch and they do not show the rotation animation on launch (only if the device is rotated after launch time).

How can I make sure my app loads in the proper orientation so the user does not see the rotation animation on launch. I would prefer it if the user only saw the rotation animation if he/she rotates the device after launching.

答:
I have done something like this in my Apps:

```<code>if ([[UIDevice currentDevice] orientation]==UIInterfaceOrientationLandscapeRight){
  [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
}else if ([[UIDevice currentDevice] orientation]==UIInterfaceOrientationLandscapeLeft){
  [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft];
}
</code>```

Simply: detect Orientation at start and then set the StatusBarOrientation to that value. If you do this before you're loading your view (or at least, so earlier like possible within your App Structure), the statusbar should appear from beginning on the right side (so theres no rotation necessary).
If you want to Support also portrait orientation, simply add 2 more else forks for them...

Body:
I have done something like this in my Apps:

if ([[UIDevice currentDevice] orientation]==UIInterfaceOrientationLandscapeRight){
  [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
}else if ([[UIDevice currentDevice] orientation]==UIInterfaceOrientationLandscapeLeft){
  [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft];
}

Simply: detect Orientation at start and then set the StatusBarOrientation to that value. If you do this before you're loading your view (or at least, so earlier like possible within your App Structure), the statusbar should appear from beginning on the right side (so theres no rotation necessary).
If you want to Support also portrait orientation, simply add 2 more else forks for them...


问:
How can I stop text block Wrapping When this line is full?

In my wpf application, I have added a text block control and set its value with Chinese and English text. But it wraps and I don't want it to wrap.

How can I resolve this problem?

答:
Add "TextBlock.TextAlignment Property" Like </p>

```<code><TextBlock Name="tbllist" Text="Your text" TextWrapping="Wrap"      TextAlignment="Justify"/>
</code>```

Body:
Add "TextBlock.TextAlignment Property" Like

<TextBlock Name="tbllist" Text="Your text" TextWrapping="Wrap"      TextAlignment="Justify"/>