Bug 27522 - Run With iOS Simulated Background Fetch Debugger does not call PerformFetch method
Summary: Run With iOS Simulated Background Fetch Debugger does not call PerformFetch m...
Status: RESOLVED ANSWERED
Alias: None
Product: iOS
Classification: Xamarin
Component: Debugger ()
Version: XI 8.6.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Rolf Bjarne Kvinge [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2015-02-27 18:32 UTC by Jon Goldberger [MSFT]
Modified: 2017-02-14 23:04 UTC (History)
5 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Test Project (20.26 KB, application/zip)
2015-02-27 18:32 UTC, Jon Goldberger [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Jon Goldberger [MSFT] 2015-02-27 18:32:44 UTC
Created attachment 10095 [details]
Test Project

## Description

When running an iOS project using Run With->iOS Simulated Background Fetch Debugger context menu, it is expected that the PerformFetch method will be called right away for debugging purposes. However this does not seem to be occurring.

## Steps to reproduce

1. Open the attached test project.

2. Right click on the project in the Solution Explorer and select Run With-> iOS Simulated Background Fetch Debugger.

Expected result: PerformFetch method will be called.

Actual result: method is not called.

## Note

Might not be a Xamarin issue, but it is also noted that PerformFetch does not seem to be called when the project is run on the simulator (after a long wait), but is called when run on device. To try to speed up when the method gets called, open and close the app a few times to make iOS think the app is used a lot which will cause PerformFetch to be called more often. The PerformFetch method was called on my device (iPhone 5s running iOS 8.1.3) after a few minutes of waiting, but not on the simulator.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2015-03-03 13:30:15 UTC
After launching (using "Run -> Run With -> iOS Simulated Background Fetch Debugger"), do "Run ->Simulate iOS Background Fetch".
Comment 2 Jon Goldberger [MSFT] 2015-03-03 14:04:32 UTC
Thanks Rolf, sorry I missed that menu item. :-(
Comment 3 Niels 2016-06-23 07:55:59 UTC
PerformFetch never called: 

I heave tried several test projects, including the one attached in this bug report but PerformFetch is never called, not on a real device, neither on a simulator. 

I have tried the "Simulate iOS Background Fetch" option and set a breakpoint in the PerformFetch method but it is never hit. I have also run the test app for a couple of days on my device but the PerformFetch is never called. The Info.plist background modes are set correctly to "Enable Background Modes" and "Background Fetch"

I am running XS 5.10.3 (build 51) on a macbook pro with osx 10.10.5.
Real devices: Iphone 6S iOS 9.3.1, iPad mini iOS 9.3.2
Simulator: iPhone 6S iOS 9.2

Am I still missing something or are there any known issues here that I should be aware of?
Comment 4 Rolf Bjarne Kvinge [MSFT] 2016-06-23 09:33:24 UTC
Simulating background fetch should work in the simulator (there was a bug where it didn't work, but we fixed that for Xamarin.iOS 9.4). Maybe you can try a sample project that is known to work to determine if there's something different with your project: https://github.com/Redth/iOS.BackgroundFetch.Sample?
Comment 5 Niels 2016-06-23 10:06:25 UTC
Hi Rolf, I have just checked the sample project you provided. This project still uses MonoTouch so I had to migrate it to Xamarin.iOS Unified API and double checked the background modes. But the same issue occurs: I have set 2 breakpoints: 
1) in FinishedLaunching
2) in PerformFetch

breakpoint #1 is hit but #2 is hollow and is never hit when running the "Simulate iOS Background Fetch" option, both on simulator and real device (iPhone 6s ios 9.3.2)

Operating System
Mac OS X 10.10.5

Xamarin Studio Business
Version 5.10.3 (build 51)

Xamarin.iOS
Version: 9.6.1.9 (Xamarin Business)

Would you be able to check on your side if this works? Thanks!
Comment 6 Niels 2016-06-23 11:29:46 UTC
Also, the Background.Sample uses the openweathermap api, which now requires an api key. After obtaining an api key I found out that the data scheme has changed, so this sample is outdated. Better use the attached sample because it doesn't use any third party api's.