Merge branch 'hotfix/tabbar_block_crash' into 'release/11_1_1'

Move hightlightTab to @MainActor to prevent block crash.

### Summary
Prevent block crash on highlight tab.

### Crash Details
https://console.firebase.google.com/project/api-project-396418606732/crashlytics/app/ios:com.vzw.hss.myverizon/issues/18516b87c36a9806e850dcac71748655?time=last-seven-days&types=crash&versions=11.1.0%20(20909.0)&sessionEventKey=bdace1e1ffa74d9b84e2afb63a98eaaf_1880252739825018670
```
0  MVMCoreUI                      0x38ad1c closure #1 in TabBar.highlightTab(at:) + 7776
1  MVMCoreUI                      0x312e8 thunk for @escaping @callee_guaranteed () -> () + 4140 (<compiler-generated>:4140)
2  MVMCore                        0xdc54 +[MVMCoreDispatchUtility performBlockOnMainThread:] + 15 (MVMCoreDispatchUtility.m:15)
3  MVMCoreUI                      0x38afe4 @objc TabBar.highlightTab(at:) + 8488
4  MobileFirstFramework           0x48f99c MVMCoreViewControllerProtocol.update(_:) + 56 (WebviewBridgeWebPageLoaded.swift:56)
```

Co-authored-by: Hedden, Kyle Matthew <kyle.hedden@verizonwireless.com>

See merge request https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui/-/merge_requests/1026
This commit is contained in:
Pfeil, Scott Robert 2023-11-15 22:33:13 +00:00
commit 440380f4d3
2 changed files with 10 additions and 12 deletions

View File

@ -82,20 +82,18 @@ import VDSColorTokens
}
// MARK: - TabBarProtocol
@MainActor
public func highlightTab(at index: Int) {
MVMCoreDispatchUtility.performBlock(onMainThread: {
guard let newSelectedItem = self.items?[index] else { return }
self.tabModel.selectedTab = index
self.selectedItem = newSelectedItem
})
guard let newSelectedItem = items?[index] else { return }
tabModel.selectedTab = index
selectedItem = newSelectedItem
}
@MainActor
public func selectTab(at index: Int) {
MVMCoreDispatchUtility.performBlock(onMainThread: {
guard let newSelectedItem = self.items?[index] else { return }
self.selectedItem = newSelectedItem
self.tabBar(self, didSelect: newSelectedItem)
})
guard let newSelectedItem = items?[index] else { return }
selectedItem = newSelectedItem
tabBar(self, didSelect: newSelectedItem)
}
public func currentTabIndex() -> Int { tabModel.selectedTab }

View File

@ -13,10 +13,10 @@ import Foundation
var delegateObject: MVMCoreUIDelegateObject? { get set }
/// Should visually select the given tab index.
@objc func highlightTab(at index: Int)
@MainActor func highlightTab(at index: Int)
/// Should select the tab index. As if the user selected it.
@objc func selectTab(at index: Int)
@MainActor func selectTab(at index: Int)
/// Returns the current tab
@objc func currentTabIndex() -> Int