Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CombinedChartView - EXC_BAD_ACCESS with doubleTapToZoomEnabled #3614

Closed
MartinPerry opened this issue Aug 29, 2018 · 6 comments
Closed

CombinedChartView - EXC_BAD_ACCESS with doubleTapToZoomEnabled #3614

MartinPerry opened this issue Aug 29, 2018 · 6 comments

Comments

@MartinPerry
Copy link

MartinPerry commented Aug 29, 2018

What did you do?

I have initialized chart with this code:

class ChartWrapper: ChartViewDelegate {

   private var chart: BarLineChartViewBase!

   func initChart() {
     let lc: CombinedChartView = CombinedChartView()
     lc.drawOrder = [DrawOrder.candle.rawValue,
                               DrawOrder.line.rawValue]
     lc.backgroundColor = UIColor.white

     chart = lc
   
     chart.delegate = self
        
     chart.dragEnabled = false
     chart.setScaleEnabled(false)
     chart.pinchZoomEnabled = false
     chart.highlightPerTapEnabled = false
     chart.doubleTapToZoomEnabled = false

     chart.leftAxis.enabled = false
     chart.rightAxis.enabled = false
     chart.legend.enabled = false
     chart.chartDescription?.enabled = false
     ... other code
  }

What did you expect to happen?

I have migrated from directly embeding Charts workspace into my worskapce to Carthage and linked it with the latest Charts 3.1.1. Before, with workspace directly in my project, all was running fine, now the crash occurs.

What happened instead?

The code crashes on line with chart.doubleTapToZoomEnabled = false

I have tried to comment out that line, but in that case it crash later on other lines.

In debug console, I can see:
Can't select by touch. No data set.
Charts was compiled with optimization - stepping may behave oddly; variables may not be available.

Charts Environment

Charts version/Branch/Commit Number: 3.1.1.
Xcode version: 9.4.1
Swift version: 4
Platform(s) running Charts: iOS
macOS version running Xcode: 10.13.6

Carthage related ?

As it turns out, this is carthage problem. If I manually embed entire Charts workspace into mine and build Framework together with my project, all is running fine.

@liuxuan30
Copy link
Member

please post the stack trace of your crash. Can't select by touch. No data set. seems something wrong with your setup?

@MartinPerry
Copy link
Author

MartinPerry commented Sep 17, 2018

Sorry for the late response.

Stack trace:

#0	0x00000001014f3260 in BarLineChartViewBase.scaleXEnabled.materializeForSet ()
#1	0x00000001005ebb80 in ChartWrapper.createChart(type:) at /Users/perry/Development/App/Forecast/ChartWrapper.swift:194
#2	0x00000001005eb278 in ChartWrapper.createActiveChart() at /Users/perry/Development/App/Forecast/ChartWrapper.swift:157
#3	0x000000010065538c in ScrollableContentView.initialize() at /Users/perry/Development/App/Forecast/ScrollableContentView.swift:152
#4	0x0000000100654a1c in ScrollableContentView.init(frame:) at /Users/perry/Development/App/Forecast/ScrollableContentView.swift:119
#5	0x0000000100654a80 in @objc ScrollableContentView.init(frame:) ()
#6	0x000000010058a1cc in @nonobjc UIView.init() ()
#7	0x0000000100571f6c in UIView.__allocating_init() ()
#8	0x0000000100645100 in ContentViewController.init(nibName:bundle:) at /Users/perry/Development/App/Forecast/ContentViewController.swift:46
#9	0x0000000100645638 in @objc ContentViewController.init(nibName:bundle:) ()
#10	0x000000010065ef60 in @nonobjc UIViewController.init() ()
#11	0x000000010065ae80 in UIViewController.__allocating_init() ()
#12	0x000000010065ad78 in ForecastPageViewController.unusedViewController(forPageIndex:) at /Users/perry/Development/App/Forecast/ForecastPageViewController.swift:71
#13	0x000000010065c128 in ForecastPageViewController.setActivePage(_:) at /Users/perry/Development/App/Forecast/ForecastPageViewController.swift:206
#14	0x000000010065d2ec in ForecastPageViewController.reloadCitiesData() at /Users/perry/Development/App/Forecast/ForecastPageViewController.swift:303
#15	0x000000010065aa14 in ForecastPageViewController.viewDidLoad() at /Users/perry/Development/App/Forecast/ForecastPageViewController.swift:45
#16	0x000000010065ac7c in @objc ForecastPageViewController.viewDidLoad() ()
#17	0x000000018dc12e64 in -[UIViewController loadViewIfRequired] ()
#18	0x000000018dc12a50 in -[UIViewController view] ()
#19	0x00000001006317c0 in ParallaxScrollViewController.childViewController.didset at /Users/perry/Development/App/UIElements/ParallaxScrollViewController.swift:116
#20	0x0000000100631bb8 in ParallaxScrollViewController.childViewController.setter ()
#21	0x0000000100576c98 in MainViewController.viewDidLoad() at /Users/perry/Development/App/MainViewController.swift:370
#22	0x0000000100577acc in @objc MainViewController.viewDidLoad() ()
#23	0x000000018dc12e64 in -[UIViewController loadViewIfRequired] ()
#24	0x000000018dc12a50 in -[UIViewController view] ()
#25	0x000000018dc03ce4 in -[UIWindow addRootViewControllerViewIfPossible] ()
#26	0x000000018dc02b18 in -[UIWindow _setHidden:forced:] ()
#27	0x000000018dc9062c in -[UIWindow makeKeyAndVisible] ()
#28	0x000000018dc06274 in -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] ()
#29	0x000000018dbd35e0 in -[UIApplication _runWithMainScene:transitionContext:completion:] ()
#30	0x000000018e203b1c in __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke ()
#31	0x000000018dbd2dd0 in +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] ()
#32	0x000000018dbd2c6c in -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] ()
#33	0x000000018dbd1afc in -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] ()
#34	0x000000018e86784c in __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke ()
#35	0x000000018dbd11ec in -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] ()
#36	0x000000018e64cac8 in __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke ()
#37	0x000000018e79abf8 in _performActionsWithDelayForTransitionContext ()
#38	0x000000018dbd0c0c in -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] ()
#39	0x000000018dbd05a8 in -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] ()
#40	0x000000018dbcd5e0 in -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] ()
#41	0x000000018dbcd330 in -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] ()
#42	0x00000001867fb470 in -[FBSSceneImpl _didCreateWithTransitionContext:completion:] ()
#43	0x0000000186803d6c in __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 ()
#44	0x0000000102da119c in _dispatch_client_callout ()
#45	0x0000000102dad7cc in _dispatch_block_invoke_direct ()
#46	0x000000018682f878 in __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ ()
#47	0x000000018682f51c in -[FBSSerialQueue _performNext] ()
#48	0x000000018682fab8 in -[FBSSerialQueue _performNextFromRunLoopSource] ()
#49	0x0000000183fa3404 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#50	0x0000000183fa2c2c in __CFRunLoopDoSources0 ()
#51	0x0000000183fa079c in __CFRunLoopRun ()
#52	0x0000000183ec0da8 in CFRunLoopRunSpecific ()
#53	0x0000000185ea5020 in GSEventRunModal ()
#54	0x000000018dedd758 in UIApplicationMain ()
#55	0x0000000100626488 in main at /Users/perry/Development/App/AppDelegate.swift:13

@liuxuan30
Copy link
Member

you should check what's going on with

#0 0x00000001014f3260 in BarLineChartViewBase.scaleXEnabled.materializeForSet ()

@MartinPerry
Copy link
Author

MartinPerry commented Sep 20, 2018

I cannot check it, since materializeForSet method is generated by Swift. It does not exist in Chart code. Stepping in debugger ends in Assembler.
It basically crash on every call of set-based property. I have comment out every line one-by-one and the crash just moves to the next call.

The main problem I see, is that only happens if I build Charts via Carthage. If I directly include them in project, no crash at all.

@liuxuan30
Copy link
Member

I think something wrong with your setup or data?

    @objc open var scaleXEnabled: Bool
    {
        get
        {
            return _scaleXEnabled
        }
        set
        {
            if _scaleXEnabled != newValue
            {
                _scaleXEnabled = newValue
                #if !os(tvOS)
                    _pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
                #endif
            }
        }
    }

you should check what you are setting.. it's weird, never see this issue before

Also, did you ChartsDemo with your config?

@MartinPerry
Copy link
Author

I have downloaded latest XCode 10/Swift 4.2 and switch to Charts 3.2.0 and it seems that the problem is gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants