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

User Tracking Mode cause crash #59

Closed
paulsUsername opened this issue Mar 29, 2021 · 1 comment · Fixed by #64
Closed

User Tracking Mode cause crash #59

paulsUsername opened this issue Mar 29, 2021 · 1 comment · Fixed by #64

Comments

@paulsUsername
Copy link

paulsUsername commented Mar 29, 2021

Every time I set the user tracking mode to .followWithHeading I get a crash. I created a bare sample project below that replicated the error. I have tested on iPhone X, and iPad, both on 14.4.1 and both get the crash after a few seconds, maybe 20 at the most.

I am not calling it from a background thread.

https://github.com/paulsUsername/maplibre-error.git

=================================================================
Main Thread Checker: UI API called on a background thread: -[UIView superview]
PID: 9527, TID: 3803024, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0
Backtrace:
4   Mapbox                              0x0000000103167fac -[MGLMapView updateUserLocationAnnotationViewAnimatedWithDuration:] + 316
5   Mapbox                              0x000000010316a974 __47-[MGLMapView locationManager:didUpdateHeading:]_block_invoke + 280
6   libdispatch.dylib                   0x00000001067cbce4 _dispatch_call_block_and_release + 24
7   libdispatch.dylib                   0x00000001067cd528 _dispatch_client_callout + 16
8   libdispatch.dylib                   0x00000001067cfcc4 _dispatch_queue_override_invoke + 888
9   libdispatch.dylib                   0x00000001067df048 _dispatch_root_queue_drain + 376
10  libdispatch.dylib                   0x00000001067df970 _dispatch_worker_thread2 + 152
11  libsystem_pthread.dylib             0x00000001c9c51568 _pthread_wqthread + 212
12  libsystem_pthread.dylib             0x00000001c9c54874 start_wqthread + 8
2021-03-28 23:01:42.214336+0100 test-123[9527:3803024] [reports] Main Thread Checker: UI API called on a background thread: -[UIView superview]
PID: 9527, TID: 3803024, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0
Backtrace:
4   Mapbox                              0x0000000103167fac -[MGLMapView updateUserLocationAnnotationViewAnimatedWithDuration:] + 316
5   Mapbox                              0x000000010316a974 __47-[MGLMapView locationManager:didUpdateHeading:]_block_invoke + 280
6   libdispatch.dylib                   0x00000001067cbce4 _dispatch_call_block_and_release + 24
7   libdispatch.dylib                   0x00000001067cd528 _dispatch_client_callout + 16
8   libdispatch.dylib                   0x00000001067cfcc4 _dispatch_queue_override_invoke + 888
9   libdispatch.dylib                   0x00000001067df048 _dispatch_root_queue_drain + 376
10  libdispatch.dylib                   0x00000001067df970 _dispatch_worker_thread2 + 152
11  libsystem_pthread.dylib             0x00000001c9c51568 _pthread_wqthread + 212
12  libsystem_pthread.dylib             0x00000001c9c54874 start_wqthread + 8
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIView bounds]
PID: 9527, TID: 3803024, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0
Backtrace:
4   Mapbox                              0x0000000103168024 -[MGLMapView updateUserLocationAnnotationViewAnimatedWithDuration:] + 436
5   Mapbox                              0x000000010316a974 __47-[MGLMapView locationManager:didUpdateHeading:]_block_invoke + 280
6   libdispatch.dylib                   0x00000001067cbce4 _dispatch_call_block_and_release + 24
7   libdispatch.dylib                   0x00000001067cd528 _dispatch_client_callout + 16
8   libdispatch.dylib                   0x00000001067cfcc4 _dispatch_queue_override_invoke + 888
9   libdispatch.dylib                   0x00000001067df048 _dispatch_root_queue_drain + 376
10  libdispatch.dylib                   0x00000001067df970 _dispatch_worker_thread2 + 152
11  libsystem_pthread.dylib             0x00000001c9c51568 _pthread_wqthread + 212
12  libsystem_pthread.dylib             0x00000001c9c54874 start_wqthread + 8
2021-03-28 23:01:42.334464+0100 test-123[9527:3803024] [reports] Main Thread Checker: UI API called on a background thread: -[UIView bounds]
PID: 9527, TID: 3803024, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0
Backtrace:
4   Mapbox                              0x0000000103168024 -[MGLMapView updateUserLocationAnnotationViewAnimatedWithDuration:] + 436
5   Mapbox                              0x000000010316a974 __47-[MGLMapView locationManager:didUpdateHeading:]_block_invoke + 280
6   libdispatch.dylib                   0x00000001067cbce4 _dispatch_call_block_and_release + 24
7   libdispatch.dylib                   0x00000001067cd528 _dispatch_client_callout + 16
8   libdispatch.dylib                   0x00000001067cfcc4 _dispatch_queue_override_invoke + 888
9   libdispatch.dylib                   0x00000001067df048 _dispatch_root_queue_drain + 376
10  libdispatch.dylib                   0x00000001067df970 _dispatch_worker_thread2 + 152
11  libsystem_pthread.dylib             0x00000001c9c51568 _pthread_wqthread + 212
12  libsystem_pthread.dylib             0x00000001c9c54874 start_wqthread + 8
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIView setCenter:]
PID: 9527, TID: 3803024, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0
Backtrace:
4   Mapbox                              0x0000000103103b00 -[MGLAnnotationView setCenter:] + 72
5   Mapbox                              0x0000000103168138 -[MGLMapView updateUserLocationAnnotationViewAnimatedWithDuration:] + 712
6   Mapbox                              0x000000010316a974 __47-[MGLMapView locationManager:didUpdateHeading:]_block_invoke + 280
7   libdispatch.dylib                   0x00000001067cbce4 _dispatch_call_block_and_release + 24
8   libdispatch.dylib                   0x00000001067cd528 _dispatch_client_callout + 16
9   libdispatch.dylib                   0x00000001067cfcc4 _dispatch_queue_override_invoke + 888
10  libdispatch.dylib                   0x00000001067df048 _dispatch_root_queue_drain + 376
11  libdispatch.dylib                   0x00000001067df970 _dispatch_worker_thread2 + 152
12  libsystem_pthread.dylib             0x00000001c9c51568 _pthread_wqthread + 212
13  libsystem_pthread.dylib             0x00000001c9c54874 start_wqthread + 8
2021-03-28 23:01:42.464651+0100 test-123[9527:3803024] [reports] Main Thread Checker: UI API called on a background thread: -[UIView setCenter:]
PID: 9527, TID: 3803024, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0
Backtrace:
4   Mapbox                              0x0000000103103b00 -[MGLAnnotationView setCenter:] + 72
5   Mapbox                              0x0000000103168138 -[MGLMapView updateUserLocationAnnotationViewAnimatedWithDuration:] + 712
6   Mapbox                              0x000000010316a974 __47-[MGLMapView locationManager:didUpdateHeading:]_block_invoke + 280
7   libdispatch.dylib                   0x00000001067cbce4 _dispatch_call_block_and_release + 24
8   libdispatch.dylib                   0x00000001067cd528 _dispatch_client_callout + 16
9   libdispatch.dylib                   0x00000001067cfcc4 _dispatch_queue_override_invoke + 888
10  libdispatch.dylib                   0x00000001067df048 _dispatch_root_queue_drain + 376
11  libdispatch.dylib                   0x00000001067df970 _dispatch_worker_thread2 + 152
12  libsystem_pthread.dylib             0x00000001c9c51568 _pthread_wqthread + 212
13  libsystem_pthread.dylib             0x00000001c9c54874 start_wqthread + 8
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIView frame]
PID: 9527, TID: 3803050, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0
Backtrace:
4   Mapbox                              0x0000000103164278 -[MGLMapView edgePaddingForFollowingWithCourse] + 92
5   Mapbox                              0x0000000103168324 -[MGLMapView userLocationAnnotationViewCenter] + 252
6   Mapbox                              0x0000000103167f30 -[MGLMapView updateUserLocationAnnotationViewAnimatedWithDuration:] + 192
7   Mapbox                              0x000000010316a974 __47-[MGLMapView locationManager:didUpdateHeading:]_block_invoke + 280
8   libdispatch.dylib                   0x00000001067cbce4 _dispatch_call_block_and_release + 24
9   libdispatch.dylib                   0x00000001067cd528 _dispatch_client_callout + 16
10  libdispatch.dylib                   0x00000001067cfcc4 _dispatch_queue_override_invoke + 888
11  libdispatch.dylib                   0x00000001067df048 _dispatch_root_queue_drain + 376
12  libdispatch.dylib                   0x00000001067df970 _dispatch_worker_thread2 + 152
13  libsystem_pthread.dylib             0x00000001c9c51568 _pthread_wqthread + 212
14  libsystem_pthread.dylib             0x00000001c9c54874 start_wqthread + 8
2021-03-28 23:01:46.983259+0100 test-123[9527:3803050] [reports] Main Thread Checker: UI API called on a background thread: -[UIView frame]
PID: 9527, TID: 3803050, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0
Backtrace:
4   Mapbox                              0x0000000103164278 -[MGLMapView edgePaddingForFollowingWithCourse] + 92
5   Mapbox                              0x0000000103168324 -[MGLMapView userLocationAnnotationViewCenter] + 252
6   Mapbox                              0x0000000103167f30 -[MGLMapView updateUserLocationAnnotationViewAnimatedWithDuration:] + 192
7   Mapbox                              0x000000010316a974 __47-[MGLMapView locationManager:didUpdateHeading:]_block_invoke + 280
8   libdispatch.dylib                   0x00000001067cbce4 _dispatch_call_block_and_release + 24
9   libdispatch.dylib                   0x00000001067cd528 _dispatch_client_callout + 16
10  libdispatch.dylib                   0x00000001067cfcc4 _dispatch_queue_override_invoke + 888
11  libdispatch.dylib                   0x00000001067df048 _dispatch_root_queue_drain + 376
12  libdispatch.dylib                   0x00000001067df970 _dispatch_worker_thread2 + 152
13  libsystem_pthread.dylib             0x00000001c9c51568 _pthread_wqthread + 212
14  libsystem_pthread.dylib             0x00000001c9c54874 start_wqthread + 8
@rruu-map
Copy link

rruu-map commented Apr 8, 2021

The problem lies in the didUpdateHeading method in the MGLMapView.mm code, remove the child thread, as follows:
// dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) {
if ( ! self->_showsUserLocation || self.pan.state == UIGestureRecognizerStateBegan || newHeading.headingAccuracy < 0) return;

    self.userLocation.heading = newHeading;

    if (self.showsUserHeadingIndicator || self.userTrackingMode == MGLUserTrackingModeFollowWithHeading)
    {
        [self updateUserLocationAnnotationView];
    }

    if ([self.delegate respondsToSelector:@selector(mapView:didUpdateUserLocation:)])
    {
        [self.delegate mapView:self didUpdateUserLocation:self.userLocation];

        if (!self->_showsUserLocation) return;
    }

    CLLocationDirection headingDirection = (newHeading.trueHeading >= 0 ? newHeading.trueHeading : newHeading.magneticHeading);

    if (headingDirection >= 0 && self.userTrackingMode == MGLUserTrackingModeFollowWithHeading
        && self.userTrackingState != MGLUserTrackingStateBegan)
    {
        [self _setDirection:headingDirection animated:YES];
        [self updateUserLocationAnnotationView];
    }

// });

reezer added a commit to reezer/maplibre-gl-native that referenced this issue Apr 14, 2021
roblabs pushed a commit that referenced this issue Apr 15, 2021
Need to follow up as to why `ios-test` unit test is failing.  But its not due to reezer's change
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

Successfully merging a pull request may close this issue.

2 participants