# App crashes playing video in background on iOS

**URL:** <https://forums.fusetools.com/t/app-crashes-playing-video-in-background-on-ios/4092>\
**Category:** Bug Reports\
**Created:** [August 1, 2016, 10:04pm UTC](https://forums.fusetools.com/t/app-crashes-playing-video-in-background-on-ios/4092 "2016-08-01T22:04:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgleason\_3](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@mgleason\_3](https://forums.fusetools.com/u/mgleason_3)\
**Post date:** [August 1, 2016, 10:04pm UTC](https://forums.fusetools.com/t/app-crashes-playing-video-in-background-on-ios/4092/1 "2016-08-01T22:04:16Z")

</div>

Fuse version 0.23.0 (build 7041) OS X El Capitan Version 10.11.6

Running the “Video Login Screen Fuse Example” in Background audio mode causes App to crash.

Steps

1. Download example project - Download and extract Zip from: [https://github.com/yupferris/fuse-example-video-login-screen/tree/master](https://github.com/yupferris/fuse-example-video-login-screen/tree/master)
2. Download video with sound - Download and extract Zip of Graham Uhelski’s “The Valley” (you need a video with audio - the original video appears to be silent) from: [http://mazwai.com/#/videos/220](http://mazwai.com/#/videos/220) 2a. Copy the video (thevalleygrahamuheslkimp4.mp4) into the assets folder
3. Edit MainView.ux 3a. On Line 31 - Change “nature.mp4” to “thevalleygrahamuheslkimp4.mp4” 3b. Save
  1. Preview on iOS - (I’m using Atom, so I right-click on the code and choose: “Fuse preview - iOS”)
  2. Turn on Background Audio - In Xcode (using 7.3.1), go to the “Capabilities” tab, turn on “Background Modes” and check: “Audio, Airplay and Picture in Picture” (next to “Modes:”)
  3. Run on iPhone - In Xcode, ensure your iPhone is plugged in and the active scheme is set to run on your iPhone and click the run button.
  4. Wait for sound - once the app is running, wait until you can hear sound from your iPhone.
  5. Press the iPhone’s On/Off button. 8a. You should continue to hear the videos music coming from your iPhone. If not, go back to step 5.
  6. Count to 3
  7. Press the iPhone’s Home Button
  8. Crashes - the app crashes with “Thread 1: EXC\_BAD\_ACCESS (code=1, address=0x1)” in Fuse.Controls.Native.iOS.GraphicsView.mm

```auto
void GraphicsView::EndDraw(uObject* handle)
{
    uStackFrame __("Fuse.Controls.Native.iOS.GraphicsView", "EndDraw(ObjC.Object)");
    @autoreleasepool
    {
        [] (::id handle) -> void
        {
            ::GLKView* glkView = (::GLKView*)handle;
            [glkView display]; // <-- Thread 1: EXC_BAD_ACCESS (code=1, address=0x1)
        } (::g::ObjC::Helpers::GetHandle(handle));

    }

}

```

---

<div class="post-metadata">

**Author:** ![mgleason\_3](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@mgleason\_3](https://forums.fusetools.com/u/mgleason_3)\
**Post date:** [August 2, 2016, 10:55pm UTC](https://forums.fusetools.com/t/app-crashes-playing-video-in-background-on-ios/4092/2 "2016-08-02T22:55:53Z")

</div>

Don’t know how display is declared, but possibly it needs to be (strong, nonatomic)?

---

<div class="post-metadata">

**Author:** ![Vegard\_Strand\_Lende](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/vegard_strand_lende/32/349_2.png) [@Vegard\_Strand\_Lende](https://forums.fusetools.com/u/Vegard_Strand_Lende)\
**Post date:** [August 3, 2016, 11:19am UTC](https://forums.fusetools.com/t/app-crashes-playing-video-in-background-on-ios/4092/3 "2016-08-03T11:19:19Z")

</div>

Hi!

Thanks for your report. I have filed an internal ticket for this issue. `display` is a method on `GLKView`, if this happens while the app is in the background I have an inkling that `GLKView` is touching resources it shouldnt when `display` is called. Kinda makes sense since the app is in the background

---

<div class="post-metadata">

**Author:** ![mgleason\_3](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@mgleason\_3](https://forums.fusetools.com/u/mgleason_3)\
**Post date:** [August 25, 2016, 8:51pm UTC](https://forums.fusetools.com/t/app-crashes-playing-video-in-background-on-ios/4092/4 "2016-08-25T20:51:09Z")

</div>

Is it possible to get an approximate date when this should be resolved?

---

<div class="post-metadata">

**Author:** ![Vegard\_Strand\_Lende](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/vegard_strand_lende/32/349_2.png) [@Vegard\_Strand\_Lende](https://forums.fusetools.com/u/Vegard_Strand_Lende)\
**Post date:** [August 26, 2016, 12:03pm UTC](https://forums.fusetools.com/t/app-crashes-playing-video-in-background-on-ios/4092/5 "2016-08-26T12:03:06Z")

</div>

Hi!

The fix is included in the upcoming release. Also, it is live now in the pre-release at [https://www.fusetools.com/downloads/channel/qa](https://www.fusetools.com/downloads/channel/qa).

---

<div class="post-metadata">

**Author:** ![mgleason\_3](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@mgleason\_3](https://forums.fusetools.com/u/mgleason_3)\
**Post date:** [August 29, 2016, 2:59am UTC](https://forums.fusetools.com/t/app-crashes-playing-video-in-background-on-ios/4092/6 "2016-08-29T02:59:37Z")

</div>

Thanks Vegard - that seems to have done it!

From time-to-time I’m getting a libsystem\_kernel.dylib`mach\_msg\_trap when returning form background mode after the app has been interrupted while in background by another audio stream - like Siri. But when I build for release, it doesn’t seem to happen so the issue might be with live-reload.

---

<div class="post-metadata">

**Author:** ![Juani\_Serra](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/juani_serra/32/463_2.png) [@Juani\_Serra](https://forums.fusetools.com/u/Juani_Serra)\
**Post date:** [August 29, 2016, 10:30pm UTC](https://forums.fusetools.com/t/app-crashes-playing-video-in-background-on-ios/4092/7 "2016-08-29T22:30:41Z")

</div>

Thanks Vegard, the last pre-release solve a really nasty bug which was crashing my app, related to `display` and `GLKView`. It seems to work perfect now, thanks!
