iOS OnlineStorev2 crashes on shutdown

This is 100%.

  1. Enable the Store v2
  2. Launch in XCode
  3. Quit your app using the OS

Output:

2017-06-13 11:01:26.340114-0700 Matchoo[876:254895] [2017.06.13-18.01.26:340][674]LogModuleManager: Shutting down and abandoning module OnlineSubsystem (32)
LogOnline:Display: FOnlineSubsystemIOS::Shutdown()
2017-06-13 11:01:26.340484-0700 Matchoo[876:254895] [2017.06.13-18.01.26:340][674]LogOnline:Display: FOnlineSubsystemIOS::Shutdown()
2017-06-13 11:01:26.346328-0700 Matchoo[876:254895] Ensure condition failed: StoreV2Interface.IsUnique() [File:/Users/thomasshepherd/MM/Engine/Plugins/Online/IOS/OnlineSubsystemIOS/Source/Private/OnlineSubsystemIOS.cpp] [Line: 234]
LogOutputDevice:Error: Ensure condition failed: StoreV2Interface.IsUnique() [File:/Users/thomasshepherd/MM/Engine/Plugins/Online/IOS/OnlineSubsystemIOS/Source/Private/OnlineSubsystemIOS.cpp] [Line: 234]
2017-06-13 11:01:26.346944-0700 Matchoo[876:254895] [2017.06.13-18.01.26:346][674]LogOutputDevice:Error: Ensure condition failed: StoreV2Interface.IsUnique() [File:/Users/thomasshepherd/MM/Engine/Plugins/Online/IOS/OnlineSubsystemIOS/Source/Private/OnlineSubsystemIOS.cpp] [Line: 234]
2017-06-13 11:01:26.347187-0700 Matchoo[876:254895] [2017.06.13-18.01.26:347][674]LogStats: FDebug::EnsureFailed -  0.002 s
Matchoo was compiled with optimization - stepping may behave oddly; variables may not be available.
(lldb) 

Callstack:

#0	0x005262bc in FIOSPlatformMisc::DebugBreak() [inlined] at /Users/thomasshepherd/MM/Engine/Source/Runtime/Core/Public/IOS/IOSPlatformMisc.h:79
#1	0x00526294 in FIOSPlatformMisc::DebugBreakAndPromptForRemoteReturningFalse(bool) [inlined] at /Users/thomasshepherd/MM/Engine/Source/Runtime/Core/Public/IOS/IOSPlatformMisc.h:103
#2	0x00526264 in UE4Asserts_Private::OptionallyDebugBreakAndPromptForRemoteReturningFalse(bool, bool) [inlined] at /Users/thomasshepherd/MM/Engine/Source/Runtime/Core/Public/Misc/AssertionMacros.h:177
#3	0x00526264 in FOnlineSubsystemIOS::Shutdown() at /Users/thomasshepherd/MM/Engine/Plugins/Online/IOS/OnlineSubsystemIOS/Source/Private/OnlineSubsystemIOS.cpp:234
#4	0x00556c24 in FOnlineSubsystemModule::ShutdownOnlineSubsystem() at /Users/thomasshepherd/MM/Engine/Plugins/Online/OnlineSubsystem/Source/Private/OnlineSubsystemModule.cpp:158
#5	0x0122929a in FModuleManager::UnloadModule(FName, bool) at /Users/thomasshepherd/MM/Engine/Source/Runtime/Core/Private/Modules/ModuleManager.cpp:553
#6	0x01229de0 in FModuleManager::UnloadModulesAtShutdown() at /Users/thomasshepherd/MM/Engine/Source/Runtime/Core/Private/Modules/ModuleManager.cpp:680
#7	0x00751b76 in FEngineLoop::Exit() at /Users/thomasshepherd/MM/Engine/Source/Runtime/Launch/Private/LaunchEngineLoop.cpp:2673
#8	0x0112d588 in ::-[IOSAppDelegate MainAppThread:](NSDictionary *) at /Users/thomasshepherd/MM/Engine/Source/Runtime/Core/Private/IOS/IOSAppDelegate.cpp:183
#9	0x1c9598aa in __NSThread__start__ ()
#10	0x1b89893a in _pthread_body ()
#11	0x1b89885c in _pthread_start ()
#12	0x1b896468 in thread_start ()

Code:

bool FOnlineSubsystemIOS::Shutdown() 
{
	bool bSuccessfullyShutdown = true;
	UE_LOG(LogOnline, Display, TEXT("FOnlineSubsystemIOS::Shutdown()"));

	bSuccessfullyShutdown = FOnlineSubsystemImpl::Shutdown();
	
#define DESTRUCT_INTERFACE(Interface) \
	if (Interface.IsValid()) \
	{ \
		ensure(Interface.IsUnique()); \
		Interface = nullptr; \
	}
	
	DESTRUCT_INTERFACE(SessionInterface);
	DESTRUCT_INTERFACE(IdentityInterface);
	DESTRUCT_INTERFACE(FriendsInterface);
	DESTRUCT_INTERFACE(LeaderboardsInterface);
	DESTRUCT_INTERFACE(AchievementsInterface);
	DESTRUCT_INTERFACE(ExternalUIInterface);
	DESTRUCT_INTERFACE(TurnBasedInterface);
	DESTRUCT_INTERFACE(UserCloudInterface);
	DESTRUCT_INTERFACE(SharedCloudInterface);
	DESTRUCT_INTERFACE(StoreInterface);
	DESTRUCT_INTERFACE(StoreV2Interface);

When you say “Quit your app using the OS”, what is the exact method you’re using to close the app? I’m pressing the home button twice and swiping the app to close it and receiving the following error:

[2017.06.21-13.04.06:818][ 97]LogOnline:Display: Unloading online subsystem: IOS
LogOnline:Display: FOnlineSubsystemIOSModule::ShutdownModule()
2017-06-21 09:04:06.819280 StoreTest[297:102681] [2017.06.21-13.04.06:819][ 97]LogOnline:Display: FOnlineSubsystemIOSModule::ShutdownModule()
LogOnline:Display: FOnlineSubsystemIOS::Shutdown()
2017-06-21 09:04:06.819502 StoreTest[297:102681] [2017.06.21-13.04.06:819][ 97]LogOnline:Display: FOnlineSubsystemIOS::Shutdown()
LogMemory:Warning: Attempting to access memory pool info for a pointer we didn't allocate!
2017-06-21 09:04:06.819683 StoreTest[297:102681] [2017.06.21-13.04.06:819][ 97]LogMemory:Warning: Attempting to access memory pool info for a pointer we didn't allocate!
LogMemory:Warning: Attempting to free a pointer we didn't allocate!
2017-06-21 09:04:06.819864 StoreTest[297:102681] [2017.06.21-13.04.06:819][ 97]LogMemory:Warning: Attempting to free a pointer we didn't allocate!
LogMemory:Warning: Attempting to access memory pool info for a pointer we didn't allocate!
2017-06-21 09:04:06.820075 StoreTest[297:102681] [2017.06.21-13.04.06:820][ 97]LogMemory:Warning: Attempting to access memory pool info for a pointer we didn't allocate!
LogMemory:Warning: Attempting to free a pointer we didn't allocate!
2017-06-21 09:04:06.820394 StoreTest[297:102681] [2017.06.21-13.04.06:820][ 97]LogMemory:Warning: Attempting to free a pointer we didn't allocate!
StoreTest(297,0x19bfb000) malloc: *** error for object 0x163e8200: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

Same approach - swipe to close.

I’m on 4.15 if that matters.

It would be good to get confirmation that we’re expected to be using the store 2.0. I had to make a minor engine code modification [which shouldn’t have any effect on this shutdown process, it’s a fix for the transaction result data when you make a purchase] to get it working for me, but it does seem to work.

According to the team who oversees it, Store V2 is fully supported but does have some bugs in that aren’t fixed in 4.16 as of yet. One of those bugs is the one that I encountered, with the double deletion of a pointer. We still haven’t seen the issue that you’re mentioning.

Would it be possible for you to try an engine version without that modification that was made to see if it could be the cause? It seems to be the only difference in our tests.

Sure but I can confirm that the code modified isn’t hit when I just boot up and shutdown my app (and hit the crash I reported).

The modification for the record is the final line in this code:

    void FOnlinePurchaseIOS::OnTransactionCompleteResponse(EPurchaseTransactionState Result, const FStoreKitTransactionData& TransactionData)
    {
  ...
    			TSharedRef<FPurchaseReceipt> FinalReceipt = UserPendingTransaction->GenerateReceipt();
                FinalReceipt->TransactionId = TransactionData.GetTransactionIdentifier();

Without this line the higher level code receiving a completion response cannot Finalize the purchase (4.15, not checked in 4.16).

Hello ,

How do you enable the Online Store v2? I’ve never had to use this before and haven’t been able to find anything about it.

There doesn’t seem to be any documentation, but in 4.15 it seems mostly functional (I’ve had to make one minor engine edit to get my consumables working). The API looks fairly well fleshed out (more than the V1 Store) but I am not sure what it’s official state is.

To enable add the following to Config/IOS/IOSEngine.ini

[OnlineSubsystemIOS.Store]
bSupportsInAppPurchasing=True
bUseStoreV2=True

Hello theonecalledtom,

Are you still experiencing this issue, and did you ever have a chance to try 4.16 or the 4.17 previews?