readium/r2-navigator-swift

Webview Crash

cNille opened this issue · 2 comments

Hi!

I updated now to r2-navigator-swift:1.1.4 and the webview crashes sometimes now when i try to start a EPUBViewController.

The only relevant change I did is to initialize the EPUBViewController with a resourcesServer and configuration object. Is there another step that I missed or something? :)

My code to start EPUBViewController.

let customInsets: [UIUserInterfaceSizeClass: EPUBContentInsets] = [
  .regular: (top: 64, bottom: 44)
]

var configuration = EPUBNavigatorViewController.Configuration()
configuration.contentInset = customInsets

epubViewer = EPUBNavigatorViewController(
    publication: publication,
    license: license,
    initialLocation: initialLocation,
    resourcesServer: server!,
    config: configuration
    )

Code that breaks - Webview.swift:

/// A custom web view which:
///  - Forwards selection actions to an EditingActionsController.
final class WebView: WKWebView {

    private let editingActions: EditingActionsController

    init(editingActions: EditingActionsController) {
        self.editingActions = editingActions
        super.init(frame: .zero, configuration: .init()) // <<< Crashes on this line
    }

Error log:

2019-10-02 11:04:04.379266+0200 Test-Bibblix[78441:944383] [Assert] Cannot be called with asCopy = NO on non-main thread.
2019-10-02 11:04:04.379551+0200 Test-Bibblix[78441:944383] [Assert] Cannot be called with asCopy = NO on non-main thread.
2019-10-02 11:04:04.393334+0200 Test-Bibblix[78441:944383] [Animation] +[UIView setAnimationsEnabled:] being called from a background thread. Performing any operation from a background thread on UIView or a subclass is not supported and may result in unexpected and insidious behavior. trace=(
	0   UIKitCore                           0x000000010e46fdda kFixedAnimationDuration_block_invoke_5 + 107
	1   libdispatch.dylib                   0x000000010691cdb5 _dispatch_client_callout + 8
	2   libdispatch.dylib                   0x000000010691e83c _dispatch_once_callout + 66
	3   UIKitCore                           0x000000010e46fd6d +[UIView(Animation) setAnimationsEnabled:] + 76
	4   UIKitCore                           0x000000010e46febb +[UIView(Animation) performWithoutAnimation:] + 84
	5   UIKitCore                           0x000000010e4327a6 -[UIImageView _updateImageViewForOldImage:newImage:] + 461
	6   UIKitCore                           0x000000010e42d649 -[UIImageView setImage:] + 369
	7   UIKitCore                           0x000000010e42c680 -[UIImageView initWithImage:] + 246
	8   UIKitCore                           0x000000010e40a0bc CreateScrollIndicator + 401
	9   UIKitCore                           0x000000010e4098af -[UIScrollView _adjustScrollerIndicators:alwaysShowingThem:] + 149
	10  UIKitCore                           0x000000010e3f998f -[UIScrollView _updateForChangedScrollIndicatorRelatedInsets] + 165
	11  WebKit                              0x0000000117db06bb -[WKScrollView initWithFrame:] + 137
	12  WebKit                              0x0000000117cab3d8 -[WKWebView _initializeWithConfiguration:] + 4866
	13  WebKit                              0x0000000117cac51c -[WKWebView initWithFrame:configuration:] + 98
	14  R2Navigator                         0x0000000102fa425b $s11R2Navigator14EPUBSpreadViewC11publication6spread12resourcesURL15initialLocation13contentLayout18readingProgression12userSettings12animatedLoad14editingActions0K5InsetAC0A6Shared11PublicationC_AA0C0V10Foundation0H0VSgAN7LocatorVAN07ContentL5StyleOAN07ReadingN0OAA04UserP0CSbAA07EditingT10ControllerCSDySo24UIUserInterfaceSizeClassV12CoreGraphics7CGFloatV3top_A9_6bottomtGtcfc + 603
	15  R2Navigator                         0x0000000102fb8a74 $s11R2Navigator24EPUBReflowableSpreadViewC11publication6spread12resourcesURL15initialLocation13contentLayout18readingProgression12userSettings12animatedLoad14editingActions0L5InsetAC0A6Shared11PublicationC_AA10EPUBSpreadV10Foundation0I0VSgAN7LocatorVAN07ContentM5StyleOAN07ReadingO0OAA04UserQ0CSbAA07EditingU10ControllerCSDySo24UIUserInterfaceSizeClassV12CoreGraphics7CGFloatV3top_A9_6bottomtGtcfc + 260
	16  R2Navigator                         0x0000000102f92857 $s11R2Navigator27EPUBNavigatorViewControllerC010paginationD0_04pageD7AtIndex8locationAA04PageD0_So6UIViewCXcSgAA010PaginationD0C_Si0A6Shared7LocatorVtFTf4dnnn_n + 1287
	17  R2Navigator                         0x0000000102f8d8ff $s11R2Navigator27EPUBNavigatorViewControllerCAA010PaginationD8DelegateA2aDP010paginationD0_04pageD7AtIndex8locationAA04PageD0_So6UIViewCXcSgAA0fD0C_Si0A6Shared7LocatorVtFTW + 15
	18  R2Navigator                         0x0000000102f96210 $s11R2Navigator14PaginationViewC04loadD033_E5B6E692643F2C92B3A81F0E647DD191LL2at8locationAA04PageD0_So6UIViewCXcSgSi_0A6Shared7LocatorVtF + 272
	19  R2Navigator                         0x0000000102f95cf4 $s11R2Navigator14PaginationViewC15setCurrentIndex33_E5B6E692643F2C92B3A81F0E647DD191LL_8locationySi_0A6Shared7LocatorVSgtF + 1972
	20  R2Navigator                         0x0000000102f94c9c $s11R2Navigator14PaginationViewC13reloadAtIndex_8location9pageCount18readingProgressionySi_0A6Shared7LocatorVSgSiAH07ReadingL0OtF + 604
	21  R2Navigator                         0x0000000102f8b4c0 $s11R2Navigator27EPUBNavigatorViewControllerC13reloadSpreads33_E158D153422E135CD1F26B7E7CA576EFLL2aty0A6Shared7LocatorVSg_tF + 1280
	22  R2Navigator                         0x0000000102f89952 $s11R2Navigator27EPUBNavigatorViewControllerC11publication7license15initialLocation15resourcesServer6configAC0A6Shared11PublicationC_AI10DRMLicense_pSgAI7LocatorVSgAI09ResourcesK0_pAC13ConfigurationVtcfc + 978
	23  R2Navigator                         0x0000000102f89564 $s11R2Navigator27EPUBNavigatorViewControllerC11publication7license15initialLocation15resourcesServer6configAC0A6Shared11PublicationC_AI10DRMLicense_pSgAI7LocatorVSgAI09ResourcesK0_pAC13ConfigurationVtcfC + 100
	24  Test-Bibblix                        0x0000000101bf41d1 $s12Test_Bibblix18EpubViewControllerC13initNavigator11publication15initialLocation7license15callbackHandler6servery8R2Shared11PublicationC_AJ7LocatorVSgAJ10DRMLicense_pSgAA015CordovaCallbackM0_p0O8Streamer0Q6ServerCSgtF + 1361

Cartfile

github "weichsel/ZIPFoundation" == 0.9.8
github "krzyzanowskim/CryptoSwift" == 0.15.0
github "readium/r2-shared-swift" == 1.3.4
github "readium/r2-streamer-swift" == 1.1.6
github "readium/r2-navigator-swift" == 1.1.4
github "readium/r2-lcp-wrapper-swift" == 1.0.8
github "readium/r2-lcp-swift" == 1.1.2
github "onevcat/Kingfisher" == 4.10.1
github "jdg/MBProgressHUD"
github "stephencelis/SQLite.swift" == 0.11.5
github "swisspol/GCDWebServer" == 3.5.2
github "edrlab/Fuzi" == 2.2.2
github "tadija/AEXML" == 4.3.3
github "dexman/Minizip"

Hello,

Can you check that you are creating EPUBNavigatorViewController from the main thread? (Thread. isMainThread)

Closing because no news.