Bug 60430 - EKEventViewController shows blacked-out screen with use of Xamarin.Google.iOS.MobileAds in iOS11
Summary: EKEventViewController shows blacked-out screen with use of Xamarin.Google.iOS...
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: XI 11.6 (xcode9.2)
Hardware: PC Windows
: Lowest minor
Target Milestone: Future Cycle (TBD)
Assignee: Israel Soto [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-10-30 02:23 UTC by Ryoichi Iwaida
Modified: 2018-04-16 11:49 UTC (History)
8 users (show)

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

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 FIXED

Description Ryoichi Iwaida 2017-10-30 02:23:21 UTC
Consider a scenario of using the module Xamarin.Firebase.iOS.AdMob to implement AdMob in Xamarin.
In such a case you would add the following code:

App.Configure();
MobileAds.Configure("<app key>");

After the configuration above, you obtain an event registered in iPhone's calendar, and show the EKEventViewController using NavigationController.PushViewController.

However, in the following conditions the event does not appear as expected, and the event view is pitch black. 
 - App is running on an iOS 11 device (iOS 10/9 armv7 doesn't show the issue)
- App is running on an actual device, not a simulator
- App is running for the first time (updates & future boots won't show the issue)
- App is accessing the calendar (the confirmation dialog of access permissions in the first-time boot is irrelevant)

Moreover, this issue persists even in codes that doesn't explicitly "run" the MobileAds.Configure line; that is, even when the line is skipped (e.g. through if statements), the issue is still seen.

[Additional Info]
Files for checking the issue are included in the attached "detail.zip" file.
The provisioning info for the Xamarin app should be changed appropriately for the testing device.  Also, the App key ID is a dummy one for testing purposes, but if the research is expected to take long, please create a new App key ID in-house.
- 01_PrivacyEvent.png: screenshot showing request of access to the Calendar
- 02_EKEventViewController.png: screenshot when issue shows (only the "delete event" button shows)
- SampleXamarin\: Sample Xamarin app which can repro the issue
- SampleSwift\: Sample Swift app which does not repro the issue
- WaCalendarCrashLog.txt: Crash logs for the crash case (described below)

Additional notes are as follows:
- The customer tried replacing Xamarin.Google.iOS.MobileAds package with a rebuilt version using the latest version of AdMob SDK, but the issue persists.
- Using PushViewController shows a black screeen, while using PresentViewController crashes the app.  
 - Using EKEventEditViewController does not repro the issue.
- To use the sample, you must create an event beforehand within September-October 2017.  Once the repro occurs, to check the issue again you must delete the app and reinstall it.

Development environment is the following:
- Windows 10 Professional
- Visual Studio 2017 Enterprise 15.3.5
- Xcode9.0 (13247 Build:9A235)
- Visual Studio for Mac (7.1.5 build 2)
- Xamarin iOS 11.0.0.0
- iPhone6s Plus(iOS 11.0、11.0.1)

There is a confrimed bug in Bugzilla that is triggered from a similar situation--the simple use of MobileAds.Configure:

  Bug 55246 - Focusing on a UITextField is slow when using Xamarin.Google.iOS.MobileAds 
  https://bugzilla.xamarin.com/show_bug.cgi?id=55246

I have a device that can repro the issue (iPhone 6s).  If you need any additional logs, feel free to let me know.
Comment 1 Ryoichi Iwaida 2017-10-30 02:27:13 UTC
You can repro the issue with sample project where is located at following share.
 \\jpddk\jesweare\shared\detailed.zip
If you cannot access there, please let me know.
Comment 2 Israel Soto [MSFT] 2017-11-25 01:40:54 UTC
@Ryoichi Iwaida I cannot download the sample, can you share the link again, please? Thanks in advance
Comment 3 Jesse 2017-11-28 06:04:28 UTC
Hello Israel, I'll be commenting on behalf of Iwaida-san on this issue.
Here's a OneDrive link to the ZIP file containing the items provided by the customer.  If you still can't access the files please let me know.

https://microsoft-my.sharepoint.com/:u:/p/jesweare/EVHz6aGHQvNBk6pLcSNYFzoBFRbjW-eNL4GfryqBslTWMw?e=1f27b81259e448db9a7f4b7d8cf4d43d

I'll note that there are some changes needed:
- Changing the provisioning profile according to your testing environment
- using a new App ID and GoogleService-Info.plist tied to your AdMob account (the one provided by the customer doesn't work anymore)
- change the line "var end_datetime = DateTime.Parse("2017/10/30");" so that the November (& later) dates are within the parsing date frame
- updating the NuGet packages

Another news is that I tested the sample app using the newest Xamarin packages (7.24.1), but the issue persists.

Thanks
Comment 4 Jesse 2017-11-30 08:59:15 UTC
@Israel

Hello, were you able to access the link above?  If there were any issues letting me know would help.

Thanks
Comment 5 Jesse 2017-12-22 07:58:25 UTC
@Israel

Could you provide a response on this?  Again, if you have any issues with accessing the share please let me know.  We could discuss this offline if you need to.

Thanks,

Jesse
Comment 6 Israel Soto [MSFT] 2018-01-08 17:09:14 UTC
Sorry for the late response.

I can download the sample. I'm working on this right now.
Comment 7 Ryoichi Iwaida 2018-01-09 10:49:18 UTC
@Israel

The latest customer's comment as follows.
------------------------------
 The originally, the problem happens on Xamarin.Google.iOS.MobileAds version 7.15.0 or later. Packages prior to version 7.15.0, I was not able to reproduce the problem.
 However, when I recently update to the latest iOS version, the problem is now observing with all versions of Xamarin.Google.iOS.MobileAds.

If this is not Xamarin specific issue then please let me know. I will ask this to Apple or Google for investigation.
------------------------------

Thanks,
Ryoichi
Comment 8 Israel Soto [MSFT] 2018-01-12 23:38:57 UTC
After some testing, I couldn't find what is causing this bug, also, tried to find a workaround for this, but with no success.

FWICT, the problem is in the view, G.MobileAds is messing with something in the view and that causes the invalidation of the entire VC.

The navigation controller seems to be working correctly. If I add a controller after the EKEventViewController, the Navigation Controller shows it correctly.

Another thing, at first, I was unable to present the EKEventViewController using PresentViewController method, this was crashing as stated before. But after updating X.iOS to v11.6.1.3, I am unable to reproduce the crash using PresentViewController method. I tested the sample right out of the box (changing the dates, of course) and everything worked as expected. Using PushViewController keeps showing a black screen.

Moving this issue to the iOS team for a further investigation.
Comment 9 Jesse 2018-01-16 09:18:37 UTC
Hi Israel, thank you very much for the update.  Understood about the current status. Again if there are any questions, please let me know.

Also, there are some updates from the customer's side, so I'd like to share those:
- Apparently the Swift version of the sample stopped working recently.  The customer is suspecting that the iOS side is playing a role in causing this issue.  If there is suitable reason that Xamarin isn't the direct cause, the customer is considering a contact to Apple/Google for investigation.
- Right now, the blackout issue occurs every time the app starts, except for the first time (i.e. the behavior is the exact opposite of what was seen before).  The customer is currently taking a patchy workaround of initializing MobileAds everytime the app goes to the foreground.
Comment 10 Sebastien Pouliot 2018-01-18 19:42:39 UTC
If a similar swift-based application shows the same issue then it's not likely to be something related to Xamarin.iOS

It's also very uncommon that bugs exhibited by only some iOS version (and not others) are related to Xamarin.iOS (we have very few version specific code paths).

That black screen situation does not seem to be unique for users of MobileAds [1][2][3] across different tools/SDK

[1] https://groups.google.com/forum/#!category-topic/google-admob-ads-sdk/ios/GKYU_IOg5kQ
[2] https://stackoverflow.com/questions/47511699/view-turns-into-black-screen-when-i-close-rewarded-video-ad-in-ios
[3] https://answers.unity.com/questions/1122524/admob-ads-are-black.html

Sadly the cases I've read (not an extensive search) did not come with any solution (beside downgrading the library in one case) and offers no clue about the root cause.

Right now we do not have any indication that this is something incorrect with Xamarin.iOS. If you get additional details please share them with us and we'll see if we can investigate this further.
Comment 11 Jesse 2018-02-16 13:20:31 UTC
Hello Sebastien, thank you for the explanation.  Also, I apologize for the extremely delayed response.

Before I mentioned that some problems are occurring in the equivalent Swift app--but I just tried to repro the issue and I don't see any problems.
The Swift sample app is no different from the original Xamarin.iOS app that shows the issue.  iOS 11.2.5 and AdMob SDK 7.28.0 is used.

Because of this observation the chance that Xamarin.iOS is playing a role in the issue can't be ruled out.  Could you investigate this issue further, based on the situation above?
If you need the project that I used, please let me know, and I'll share a link to the share.
Comment 12 Sebastien Pouliot 2018-02-16 13:48:09 UTC
@Jesse sure, please share the latest sample versions you have (both swift and XI) and include the version information (of XI being used).

Note that the other links I shared shows the same issue without Xamarin.iOS so, right now, my guess remains it's not related - it's something else, e.g. could be a race, that the XI sample shows.
Comment 13 Jesse 2018-03-02 04:01:39 UTC
Thank you Sebastien.

I placed the projects for each sample in my OneDrive (due to large sizes).  Here are the links.  Let me know if there are any access issues.

Xamarin sample:
https://microsoft-my.sharepoint.com/:u:/p/jesweare/EVcDwnRNOg1HmcVFFENc4UQBpG5_2ITevr7PhRkCbL3NrA?e=R1MOv9

Swift sample:
https://microsoft-my.sharepoint.com/:u:/p/jesweare/EVTxNWzJEXxFqt19X7yKqmkBXehRSTgzFW5kuWABxFKsUA?e=zedlf9


For the Xamarin sample, I just tested it today with the most recent Xamarin environment and an iPhone6s with iOS 11.2.5 installed.  MobileAds is 7.24.1.
Here is the actual version info for Xamarin:

Xamarin   4.8.0.760 (fc93f3f5b)
Xamarin Designer   4.8.188 (c5813fa34)
Xamarin.Android SDK   8.1.5.0 (HEAD/75f8c6838)
Xamarin.iOS and Xamarin.Mac SDK   11.6.1.4 (db807ec)

For the Swift sample, I would like to note that I'm not familiar with Swift at all so there may be something missing that causes the issue to not appear.
Comment 14 Jesse 2018-03-16 06:48:31 UTC
Hello,

Just a quick check on whether the comparison between Xamarin.iOS and Swift worked fine based on the files I provided.  If there were any problems in testing the projects, please let me know.

Thanks
Comment 15 Jesse 2018-03-29 09:11:39 UTC
Hi, another quick check on the status of this.  It would be nice if you could let me know whether the repro status (yes on Xamarin, no on Swift) could be seen on your side as well.

Thanks
Comment 16 Manuel de la Peña [MSFT] 2018-04-09 14:51:52 UTC
Hello,

I'll be taking over the bug. I just started looking into it, I'll provide feedback ASAP.
Comment 17 Manuel de la Peña [MSFT] 2018-04-12 09:22:10 UTC
So, I have been looking at the application. In the given version, the application crashes, nevertheless, testing the application with the following environment (pasted at the end of the comments) results in the application running without a crash where we have a dialog displayed to add a new event and going back to the main screen (with the Display Event button). I request @Israel to do the same test and he confirmed that it worked, can you please upgrade to the following and get back to me either confirming that the bug goes not longer occur? 

Environment:

=== Visual Studio Community 2017 for Mac ===

Version Preview - Internal Dogfood (7.4.2 build 7)
Installation UUID: 8d12e55e-3489-463f-ac52-8cb4573c5a81
Runtime:
	Mono 5.8.1.0 (2017-10/6bf3922f3fd) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 508010000

=== NuGet ===

Version: 4.3.1.4445

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	2.0.5
	2.0.0
	1.1.2
	1.0.5
	1.0.0
SDK: /usr/local/share/dotnet/sdk/2.1.4/Sdks
SDK Versions:
	2.1.4
	2.0.0
	1.0.4
	1.0.0-preview2-003121
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.8.1/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.1
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 9.3 (14126.4)
Build 9Q117m

=== Xamarin.Mac ===

Version: 4.2.1.28 (Visual Studio Community)

=== Xamarin.iOS ===

Version: 11.9.1.24 (Visual Studio Community)
Hash: f62de472
Branch: xcode9.3
Build date: 2018-03-29 19:30:53-0400

=== Xamarin.Android ===

Version: 8.2.0.16 (Visual Studio Community)
Android SDK: /Users/mandel/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.0.3 (API level 15)
		4.3   (API level 18)
		4.4   (API level 19)
		5.0   (API level 21)
		6.0   (API level 23)
		7.0   (API level 24)
		7.1   (API level 25)

SDK Tools Version: 25.2.5
SDK Platform Tools Version: 25.0.4
SDK Build Tools Version: 25.0.1

Java SDK: /usr
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Inspector ===

Version: 1.4.0
Hash: b3f92f9
Branch: master
Build date: Fri, 19 Jan 2018 22:00:34 GMT
Client compatibility: 1

=== Build Information ===

Release ID: 704020007
Git revision: 6b8c9cfce198dcb66fabb49295f37e5b2b5195ee
Build date: 2018-03-26 15:23:41-04
Xamarin addins: b043a56a617644b4cbdea3c6fdacf9f1502f3a9d
Build lane: monodevelop-lion-dogfood-vNext

=== Operating System ===

Mac OS X 10.13.4
Darwin 17.5.0 Darwin Kernel Version 17.5.0
    Mon Mar  5 22:24:32 PST 2018
    root:xnu-4570.51.1~1/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

WakaTime 3.0.2
Internet of Things (IoT) development (Preview) 7.1
Comment 18 Ryoichi Iwaida 2018-04-16 11:47:33 UTC
Thank you, Manuel.

I have tested on the latest environment. The result was the same which you have done. The problem did not happen.
Comment 19 Manuel de la Peña [MSFT] 2018-04-16 11:49:00 UTC
@Ryoichi superb news. Will close the bug as fixed for QA to double check. Thanks for the feedback.