React Native應自動回退使用脫機捆綁軟件,如果它找不到正在運行的打包程序,它將在第一次運行時保存它。這在Running react-native app on iOS device using offline bundle中提及。React Native開發模式應用程序不會回退到物理設備上的脫機捆綁包(ios)
但是,在我的情況下,從WiFi斷開手機並啓動應用程序後,它只是掛在預先緩存的頁面(或頁面圖像)上,而且通常是最後一個加載的頁面(即最後一頁當應用程序連接到打包程序時加載的頁面)。這是違反直覺的,因爲你認爲關閉應用後,它不會持續任何本地狀態。
我不知道爲什麼會發生這種情況在我的情況。這是來自我的設備的相關日誌跟蹤,它在isPackagerRunning
中崩潰,似乎正試圖對URL進行一些排序請求。它應該甚至試圖做到這一點?我可以嘗試記錄它試圖連接到的URL,我想。
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x0000000186eaf260 semaphore_wait_trap + 8
1 libdispatch.dylib 0x0000000186d9d5e8 _os_semaphore_wait + 24
2 libdispatch.dylib 0x0000000186d9cca0 _dispatch_semaphore_wait_slow + 140
3 CFNetwork 0x000000018858eb9c CFURLConnectionSendSynchronousRequest + 284
4 CFNetwork 0x00000001885bb154 +[NSURLConnection sendSynchronousRequest:returningResponse:error:] + 120
5 resiShare 0x00000001003d4334 -[RCTBundleURLProvider isPackagerRunning:] (RCTBundleURLProvider.m:76)
6 resiShare 0x00000001003d45e4 -[RCTBundleURLProvider guessPackagerHost] (RCTBundleURLProvider.m:92)
7 resiShare 0x00000001003d47f4 -[RCTBundleURLProvider packagerServerHost] (RCTBundleURLProvider.m:106)
8 resiShare 0x00000001003d49b8 -[RCTBundleURLProvider jsBundleURLForBundleRoot:fallbackResource:] (RCTBundleURLProvider.m:123)
9 resiShare 0x00000001000cad6c -[AppDelegate application:didFinishLaunchingWithOptions:] (AppDelegate.m:23)
10 UIKit 0x000000018e0732dc -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 380
11 UIKit 0x000000018e27f800 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3452
12 UIKit 0x000000018e2852a8 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1684
13 UIKit 0x000000018e299de0 __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke.3151 + 48
14 UIKit 0x000000018e28253c -[UIApplication workspaceDidEndTransaction:] + 168
15 FrontBoardServices 0x0000000189a7b884 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36
16 FrontBoardServices 0x0000000189a7b6f0 -[FBSSerialQueue _performNext] + 176
17 FrontBoardServices 0x0000000189a7baa0 -[FBSSerialQueue _performNextFromRunLoopSource] + 56
18 CoreFoundation 0x0000000187e81424 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
19 CoreFoundation 0x0000000187e80d94 __CFRunLoopDoSources0 + 540
20 CoreFoundation 0x0000000187e7e9a0 __CFRunLoopRun + 744
21 CoreFoundation 0x0000000187daed94 CFRunLoopRunSpecific + 424
22 UIKit 0x000000018e06c45c -[UIApplication _run] + 652
23 UIKit 0x000000018e067130 UIApplicationMain + 208
24 resiShare 0x00000001000cb1d0 main (main.m:16)
25 libdyld.dylib 0x0000000186dbd59c start + 4