Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
Separating this issue out from bug #37536. Originally we suspected that the two were related, but it appears they are not, since the workaround only fixes the crash, not the rendering issue. The actual fix has not been released, though, so we are only assuming that it addresses only the crash as well.
You can repro this bug using the repro solution attached to #37536.
Copying the description here for reference:
The repro app displays a custom animation control. The control loops through 70 different pre-loaded CGImages (one every 20 ms) and draws them using CGContext.DrawImage.
PROBLEM: Around 80% of the images are not rendered on the screen at all, even though the DrawImage call succeeds. This occurs ONLY when the app is run on an actual iPad, and not in the iOS simulator.
This is serious issue affecting one of the major visuals in a consumer product. If someone could take a look at this long enough to at least suggest a workaround that would be extremely helpful.
- The same specific images fail to render every time.
- All of the images render correctly in the iOS simulator, in an Android emulator, on an Android device, and in a number of different image viewers/editors on both Windows and Mac.
- We opened and re-saved the images using an image tool, which resulted in somewhat different file sizes, but it did not resolve the issue.
If I apply the fix here: https://gist.github.com/rolfbjarne/1452c400fbbbe7da071f the earth seems to spin fine on device for me (same as it does on the simulator) - but there is a hiccup when it loops (I assume that's expected?)
Is anything printed to the iOS Device log (in Xamarin Studio's View -> Pads -> iOS Device Log) and/or the Application Output when running on device?
Also which device(s) have you tried on (and which iOS versions do those devices have)?
Yes, the hiccup is actually expected. While investigating the issue we reordered some of the images, then inadvertently left them that way. When they are in the right order there's no hiccup. :)
Nothing is showing up for us in either the iOS Device log or in Application Output when the issue occurs.
Device notes from the original bug:
Simulator: iPad 2, iOS 9.2
Device: iPad 4, iOS 9.2
Some specific image #'s that do/don't render:
BAD: 2-6, most of the range 0-40
Confirmed repro on a second iPad 4, both running iOS 9.2.1. One has 16 GB, the other 32 GB storage. Otherwise identical.
Created attachment 14771 [details]
fixed test case
I'm attaching the code I'm running, can you try this code so that we can make sure we're running the exact same code?
Your code won't build for us. We have Xamarin.iOS 22.214.171.124, which has no CGDataProvider(byte buffer) overload (although it would be nice if it did). The original code calls CGDataProvider(byte, int, int).
It looks like you made some other changes too, including some project settings. If we revert the constructor call mentioned above, the code builds, but will not deploy:
Installing application bundle
error MT1006: Could not install the application '/.../HelloWorld.iOS.app' on the device Demo32: AMDeviceSecureInstallApplicationBundle returned: 0xe8000087 (kAMDIncorrectArchitectureError).
So I can reproduce your problem now (I couldn't earlier because I was using a newer version of Xamarin.iOS with an additional fix for CGDataProvider).
The bug is that the image data is freed when the GC collects CGDataProvider, and if the CGImage tries to fetch the image data after that, you'll get random behavior (or even crashes).
There are at least two workarounds:
* Make sure the CGDataProvider is not freed by the GC. One simple way of doing this is to add them to a static list (https://gist.github.com/rolfbjarne/2d5c19ef879387ee1b6f), but this might be a problem if you have many images (it uses memory).
* Another option is to store the image data in a file and use the CGDataProvider's constructor that takes a filename.
*** This bug has been marked as a duplicate of bug 34633 ***
You can also update to the latest service release (from yesterday), where this issue is fixed and your code works just fine.