iOS Multitasking

My cmake file seems correct. I checked with master branch and there were no warnings regarding fullscreen not beeing set. I reproduce the issue with the develop branch. What branch were you using ?

juce_add_plugin(${PROJECT_NAME}
    PRODUCT_NAME  ${PROJECT_NAME}
    VERSION ${VERSION}
    BUNDLE_ID ${VENDOR_IDENTIFIER}.${PROJECT_NAME}
    COMPANY_NAME "XXX"
    COMPANY_WEBSITE "XXX"
    COMPANY_EMAIL "XXX"
    COMPANY_COPYRIGHT ${COPYRIGHT}
    IS_SYNTH FALSE
    NEEDS_MIDI_INPUT TRUE
    NEEDS_MIDI_OUTPUT FALSE
    IS_MIDI_EFFECT FALSE
    EDITOR_WANTS_KEYBOARD_FOCUS TRUE
    PLUGIN_MANUFACTURER_CODE "XXX "
    PLUGIN_CODE "XXXX"
    AAX_CATEGORY AAX_ePlugInCategory_Reverb
    COPY_PLUGIN_AFTER_BUILD TRUE
    SUPPRESS_AU_PLIST_RESOURCE_USAGE TRUE
    CUSTOM_XCASSETS_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/Images.xcassets
    TARGETED_DEVICE_FAMILY "1,2" # iPhone and iPad
    REQUIRES_FULL_SCREEN TRUE
    IPAD_SCREEN_ORIENTATIONS UIInterfaceOrientationLandscapeRight UIInterfaceOrientationLandscapeLeft
    IPHONE_SCREEN_ORIENTATIONS UIInterfaceOrientationLandscapeRight UIInterfaceOrientationLandscapeLeft
    BACKGROUND_AUDIO_ENABLED TRUE
    APP_GROUPS_ENABLED TRUE
    ICLOUD_PERMISSIONS_ENABLED TRUE
    MICROPHONE_PERMISSION_ENABLED TRUE
    MICROPHONE_PERMISSION_TEXT "${PROJECT_NAME} requires microphone usage"
    APP_GROUP_IDS group.${VENDOR_IDENTIFIER}.${PROJECT_NAME}
    PLIST_TO_MERGE ${PLIST_TO_MERGE}}
    FORMATS ${FORMATS})

This commit is linked with my trouble:

iOS: Added options to the Projucer and CMake to set UIRequiresFullScreen .plist option 65f2de3de ed <eddavies95@gmail.com> 5 Feb 2021 at 12:34

it seems that requiresFullScreen is never true no matter what I set in REQUIRES_FULL_SCREEN

 if (iOS)
    {
        if (type != ProjectType::Target::AudioUnitv3PlugIn)
        {
            if (statusBarHidden)
                addPlistDictionaryKey (*dict, "UIStatusBarHidden", true);

            if (requiresFullScreen) //works if commented (old behavior)
                addPlistDictionaryKey (*dict, "UIRequiresFullScreen", true);

            addIosScreenOrientations (*dict);
            addIosBackgroundModes (*dict);
        }

You need all four user interface orientations enabled, in order for multitasking to work. It looks like you’ve only enabled the landscape orientations, so you should enable the portrait orientations too.

I’ve been using the develop branch. Multitasking definitely works in the DemoRunner on that branch.

I do not intend to use the multitasking, My app only supports landscape.
I am addressing a potential regression when the multitasking support has been provided within juce cmake.

The issue is when multitasking is disabled because UIRequiresFullScreen is never (beeing true or false) set in the plist.

Thanks, I understand the issue now. I’ll get that patched on develop.

1 Like

Hi @reuk

I’m sorry to report I’ve (just) now come across a problem with this change.

The issue is that orientation changes work fine on iOS Simulators, but we’ve found they’ve stopped responding to orientation changes with physical devices. It looks like some sort of timing related issue in the Juce code. Maybe there is a recent iOS change that has aggravated this?

Anyhow, I’ve this morning had to revert back to my own split screen handling code, where orientation changes are all picked up fine (and split-screen still works, of course).
juce_ios_WIndowing.mm
juce_ios_UIViewComponentPeer.mm

If you’d like my copy of the code, just send me a mail, I’d be happy to give it to you of course!

Best wishes,

Pete

See also: juce_ios_UIViewComponentPeer.mm - #4 by peteatjuce

Unfortunately I only have newer iOS devices here for testing. On an iPhone SE 2 and a recent iPad the screen rotation seems to work correctly in the DemoRunner.

My best guess for the broken commit would be this:

Is there any chance you could try reverting just this commit (i.e. git checkout develop; git revert 04f2ca61) and check whether that resolves the issue for you?

Hi @reuk,

Thanks for the suggestion! I’ll try to do that today or tomorrow. Either way, I’ll report back to you as soon as I’ve tried it!

Pete

Hi @reuk

That seems to work but if you were to revert, I would strongly suggest you use the following chunk of code (which I use in my own patched-up implementation, and have used ever since I implemented my own split-screen implementation).

- (void) viewWillTransitionToSize: (CGSize) size withTransitionCoordinator: (id<UIViewControllerTransitionCoordinator>) coordinator
{
    [super viewWillTransitionToSize: size withTransitionCoordinator: coordinator];
    [coordinator animateAlongsideTransition: nil completion: ^void (id<UIViewControllerTransitionCoordinatorContext>)
    {
        sendScreenBoundsUpdate (self);
    }];
}

Hoping that helps!

Pete

Thanks for trying that out. Are you saying that when the commit is reverted, but the implementation of viewWillTransitionToSize is implemented as above, iOS rotation works consistently for you?

Hi @reuk

Yes, exactly as you described :slight_smile:

Let me know if I can be of any additional help!

Pete

NB I’m just now re-checking that Split-Screen works on iPad… if you don’t hear back from me, it is working fine…

Thanks for replying. Unfortunately I’m a bit confused - if I revert the patch but leave viewWillTransitionToSize as it is above, the effect of the patch is just to add in the AsyncBoundsUpdater class, and to add it as a data member of JuceUIViewController. However, the triggerAsyncUpdate function is never called on this object.

Are you sure the body of the animation callback is correct above? Should that be calling triggerAsyncUpdate on the bounds updater, instead of calling sendScreenBoundsUpdate directly?

Certainly works for me.

Yeah - good point, you’re right - it means that AsyncBoundsUpdater isn’t called.

Works perfectly!

If you DM me (or mail me at intermorphic.com) to give me your mail address, I’ll mail you the exact version of the code I’m using.

It contains my tvOS patches, and a few other patches (all clearly commented/marked!) - nothing major.

Best wishes,

Pete

Just use pete@ …

FWIW, we’ll now test out this version internally, and report back if we see any problems. HTH! Pete

This is what I’m finding confusing. If the AsyncBoundsUpdater is never actually used, why would adding it back in have any effect? I think there must be something else going on here.

Could you tell me which devices + OS combinations have been causing problems for you?

Hi @reuk,

Well, the reverted version works as you say. I’ve just now rechecked for you as requested.

I’ve made the change below, but at this point in time it doesn’t seem to make any difference which of the versions below I use (though I’ll stick to my modified version).

So, it seems to work (reverted) with or without AsyncBoundsUpdater - but the version with coordinator animateAlongsideTransition (which doesn’t use AsyncBoundsUpdater ) is the one that looks most “iOS safe” to me, so I’ll stick with that approach in my own builds for now…!

My change: from this:

    // On some devices the screen-size isn't yet updated at this point, so also trigger another
    // async update to double-check..
    if (boundsUpdater != nullptr)
        boundsUpdater->triggerAsyncUpdate();

To this:

    [coordinator animateAlongsideTransition: nil completion: ^void (id<UIViewControllerTransitionCoordinatorContext>)
    {
        sendScreenBoundsUpdate (self);
    }];

Best wishes,

Pete