Skip to content

fix(ios): fix containment issues once and for all#14397

Open
hansemannn wants to merge 1 commit intotidev:mainfrom
hansemannn:fix/containment-bugs
Open

fix(ios): fix containment issues once and for all#14397
hansemannn wants to merge 1 commit intotidev:mainfrom
hansemannn:fix/containment-bugs

Conversation

@hansemannn
Copy link
Copy Markdown
Collaborator

A follow-up of #14261 with a more focussed approach of recognizing different containment references and comparing them. Also fixing this (related) issue:

  Calling -viewDidAppear: directly on a view controller is not supported, and may result in out-of-order callbacks and other inconsistent behavior. Use the -beginAppearanceTransition:animated: and -endAppearanceTransition APIs on          
  UIViewController to manually drive appearance callbacks instead. Make a symbolic breakpoint at UIViewControllerAlertForAppearanceCallbackMisuse to catch this in the debugger. View controller: <UINavigationController: 0x105833000> 

@hansemannn
Copy link
Copy Markdown
Collaborator Author

Hey @designbymind, would you mind giving this one a shot? As the other one broke your setup and was reproducible, this one should either also crash or work :)

@designbymind
Copy link
Copy Markdown

Hey @hansemannn, I've tried building with these latest commits but I'm still getting back the error below. Just to add some additional context here, I am attempting to add a Ti TabGroup to the center window of a drawer instance (by using a version of this module).

Error

Last Exception Backtrace:
0   CoreFoundation                	       0x10bca01c4 __exceptionPreprocess + 160
1   libobjc.A.dylib               	       0x105580094 objc_exception_throw + 72
2   CoreFoundation                	       0x10bca00e0 -[NSException initWithCoder:] + 0
3   UIKitCore                     	       0x1548646a0 -[UIView(Hierarchy) _associatedViewControllerForwardsAppearanceCallbacks:performHierarchyCheck:isRoot:] + 216
4   UIKitCore                     	       0x154864e60 -[UIView(Hierarchy) _willMoveToWindow:withAncestorView:] + 184
5   UIKitCore                     	       0x1548728b8 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 368
6   AppName                      	       0x104aef2f8 __21-[TiUITabGroup open:]_block_invoke + 240 (TiUITabGroup.m:711)
7   libdispatch.dylib             	       0x10eefd7a8 _dispatch_call_block_and_release + 24
8   libdispatch.dylib             	       0x10ef184b0 _dispatch_client_callout + 12
9   libdispatch.dylib             	       0x10ef344a0 <deduplicated_symbol> + 24
10  libdispatch.dylib             	       0x10ef0d31c _dispatch_main_queue_drain + 1184
11  libdispatch.dylib             	       0x10ef0ce6c _dispatch_main_queue_callback_4CF + 40
12  CoreFoundation                	       0x10bbfeed8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
13  CoreFoundation                	       0x10bbfe0b0 __CFRunLoopRun + 1884
14  CoreFoundation                	       0x10bbf8cec _CFRunLoopRunSpecificWithOptions + 496
15  GraphicsServices              	       0x11fe729bc GSEventRunModal + 116
16  UIKitCore                     	       0x1542aa574 -[UIApplication _run] + 772
17  UIKitCore                     	       0x1542ae79c UIApplicationMain + 124
18  AppName                      	       0x104af0b44 main + 800 (main.m:70)
19  ???                           	       0x1050e93d0 ???
20  dyld                          	       0x1053d0d54 start + 7184

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	       0x11433c85c __pthread_kill + 8
1   libsystem_pthread.dylib       	       0x11445a2a8 pthread_kill + 264
2   libsystem_c.dylib             	       0x1141d0a0c __abort + 108
3   libsystem_c.dylib             	       0x1141d09a0 abort + 112
4   libc++abi.dylib               	       0x1075c926c __abort_message + 128
5   libc++abi.dylib               	       0x1075b91a4 demangling_terminate_handler() + 268
6   libobjc.A.dylib               	       0x10555b218 _objc_terminate() + 124
7   libc++abi.dylib               	       0x1075c8758 std::__terminate(void (*)()) + 12
8   libc++abi.dylib               	       0x1075cb7c0 __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 32
9   libc++abi.dylib               	       0x1075cb7a0 __cxa_throw + 88
10  libobjc.A.dylib               	       0x1055801cc objc_exception_throw + 384
11  CoreFoundation                	       0x10bca00e0 +[NSException raise:format:] + 124
12  UIKitCore                     	       0x1548646a0 -[UIView(Hierarchy) _associatedViewControllerForwardsAppearanceCallbacks:performHierarchyCheck:isRoot:] + 216
13  UIKitCore                     	       0x154864e60 -[UIView(Hierarchy) _willMoveToWindow:withAncestorView:] + 184
14  UIKitCore                     	       0x1548728b8 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 368
15  AppName                      	       0x104aef2f8 __21-[TiUITabGroup open:]_block_invoke + 240 (TiUITabGroup.m:711)
16  libdispatch.dylib             	       0x10eefd7a8 _dispatch_call_block_and_release + 24
17  libdispatch.dylib             	       0x10ef184b0 _dispatch_client_callout + 12
18  libdispatch.dylib             	       0x10ef344a0 <deduplicated_symbol> + 24
19  libdispatch.dylib             	       0x10ef0d31c _dispatch_main_queue_drain + 1184
20  libdispatch.dylib             	       0x10ef0ce6c _dispatch_main_queue_callback_4CF + 40
21  CoreFoundation                	       0x10bbfeed8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
22  CoreFoundation                	       0x10bbfe0b0 __CFRunLoopRun + 1884
23  CoreFoundation                	       0x10bbf8cec _CFRunLoopRunSpecificWithOptions + 496
24  GraphicsServices              	       0x11fe729bc GSEventRunModal + 116
25  UIKitCore                     	       0x1542aa574 -[UIApplication _run] + 772
26  UIKitCore                     	       0x1542ae79c UIApplicationMain + 124
27  AppName                      	       0x104af0b44 main + 800 (main.m:70)
28  ???                           	       0x1050e93d0 ???
29  dyld                          	       0x1053d0d54 start + 7184

@hansemannn
Copy link
Copy Markdown
Collaborator Author

Ohhh, okay. The drawer module is external and likely needs fixes as well after these fixes in the SDK. Can you peovide a minimal repro?

@designbymind
Copy link
Copy Markdown

designbymind commented Feb 25, 2026

This should help. It's super minimal, just enough to reproduce. Do you want full GH repo or will this work for testing?

/*
TiSDK: 13.1.0.GA
Required Module:
Link: https://github.com/mbender74/NappDrawer
Include: <module platform="iphone" version="2.2.7">dk.napp.drawer</module>
*/

const NappDrawerModule = require('dk.napp.drawer');

const drawer = NappDrawerModule.createDrawer({
	width: Ti.Platform.displayCaps.platformWidth,
	orientationModes: [Ti.UI.PORTRAIT],
	backgroundColor: '#000000',
	animationMode: NappDrawerModule.ANIMATION_SLIDE,
	closeDrawerGestureMode: NappDrawerModule.CLOSE_MODE_ALL,
	openDrawerGestureMode: NappDrawerModule.OPEN_MODE_NONE,
	shouldStretchDrawer: false,
	showShadow: false,
	animationVelocity: 1300,
	leftDrawerWidth: Ti.Platform.displayCaps.platformWidth,
	rightDrawerWidth: Ti.Platform.displayCaps.platformWidth
});

// Create Drawers
const leftDrawerWindow = Ti.UI.createWindow({
	title: 'Left Drawer',
	backgroundColor: '#FFFFFF'
});

const leftDrawer = Ti.UI.createNavigationWindow({
	window: leftDrawerWindow
});

const rightDrawerWindow = Ti.UI.createWindow({
	title: 'Right Drawer',
	backgroundColor: '#FFFFFF'
});

const rightDrawer = Ti.UI.createNavigationWindow({
	window: rightDrawerWindow
});

const win1 = Ti.UI.createWindow({
	backgroundColor: 'blue',
	title: 'Blue'
});
win1.add(Ti.UI.createLabel({ text: 'I am a blue window.' }));

const win2 = Ti.UI.createWindow({
	backgroundColor: 'red',
	title: 'Red'
});
win2.add(Ti.UI.createLabel({ text: 'I am a red window.' }));

const tab1 = Ti.UI.createTab({
		window: win1,
		title: 'Blue'
	}),
	tab2 = Ti.UI.createTab({
		window: win2,
		title: 'Red'
	}),
	tabGroup = Ti.UI.createTabGroup({
		tabs: [tab1, tab2]
	});

// Open our TabGroup (crashes with or without opening)
// tabGroup.open();

// --- Set drawer Windows ---
drawer.leftWindow = leftDrawer;
drawer.rightWindow = rightDrawer;
drawer.centerWindow = tabGroup;

// Open the drawer
drawer.open();

// Should crash with the error reported at the link below:
// https://github.com/tidev/titanium-sdk/pull/14397#issuecomment-3956428982

@designbymind
Copy link
Copy Markdown

Note: The commits made here work with a normal TabGroup implementation on my end (not contained in drawer module). Thought this was worth mentioning...

@hansemannn
Copy link
Copy Markdown
Collaborator Author

@designbymind Which fork of napp-drawer do you use? I will try to fix that module as well

@designbymind
Copy link
Copy Markdown

@hansemannn I'm just now seeing your comment. There are quite a few forks, but I'm almost positive that I'm currently using this one. A fix would be really awesome as I'm pretty sure the module is a very popular one, I see it frequently mentioned in TiSlack...

@hansemannn
Copy link
Copy Markdown
Collaborator Author

Can you try dk.napp.drawer-iphone-3.0.0.zip?

@designbymind
Copy link
Copy Markdown

Just gave the NappDrawer 3.0.0 module build a try and it's returning the exact same error as above. This is with the commits patched in from this PR. Grrrrr 🤷‍♂️

@hansemannn
Copy link
Copy Markdown
Collaborator Author

Try this one?

dk.napp.drawer-iphone-3.0.0.zip

@designbymind
Copy link
Copy Markdown

Hmmm. Same exact error 🫤

@hansemannn
Copy link
Copy Markdown
Collaborator Author

Weird. Exact crash line by line? can you double check it's the right module version?

@designbymind
Copy link
Copy Markdown

I just reinstalled the latest 3.0.0, triple-checked module version being used, cleaned project, built again (using the test app above with TiSDK 13.1.1.GA patched with this PR) and am receiving the same error (sent full report via Slack in case of sensitive into in report)...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants