Feature #74

OS X support - make ETL apple client mod compatible

Added by IR4T4 almost 7 years ago. Updated over 4 years ago.

Status:Fixed% Done:

100%

Priority:HighSpent time:7.00 hours
Assignee:Radegast
Category:General
Target version:2.71rc4
OS:OS X Arch:

Description

Current status of Mac OS X support:

  • Silent, ETRun and Legacy mod are compatible
  • other mods crash (mods compiled for ppc arch)

Related issues

Related to ET: Legacy Development - Bug #187: OGG vorbis playback in 32bit ET:L under Mac OS X doesn't ... Invalid 01.02.2013
Related to ET: Legacy Development - Bug #243: Mac OSX Joystick Support Invalid 13.03.2013
Related to ET: Legacy Development - Bug #385: Receiving SIGIOT on MacOSX Fixed 01.11.2013
Related to ET: Legacy Development - Bug #387: GLimp_InitOpenGL3xContext fails on MacOSX by design - but... Fixed 01.11.2013
Related to ET: Legacy Development - Bug #355: glsl2c.sed script for processing glsl files is broken on ... Fixed 30.09.2013
Blocked by ET: Legacy Development - Bug #84: ET:L compiled with Clang or gcc-llvm crashes Fixed 07.10.2012
Follows ET: Legacy Development - Bug #462: Don't use hardcoded Application Support path on Mac Fixed 01.01.2014

Associated revisions

Revision 8d127fa5
Added by Radegast over 6 years ago

general: use lib bundle instead of dylib on Mac, refs #74

Revision 4a713571
Added by Radegast over 6 years ago

general: disabled clang/gcc-llvm build because I always forget about it, refs #74

Revision 85ca9b4e
Added by IR4T4 over 6 years ago

idSqrt activated again (used in CL_MouseMove see rate)- this should fix
borked mouse acceleration for MAC OS X refs #74 ... it’s vanilla code
and works 'well’ for MAC mod builds

Revision 8e87e11e
Added by IR4T4 over 6 years ago

reverted a previous commit refs #74 - ET:L uses BSD Library functions
for OS X sqrt

Revision 6e5da29a
Added by Radegast over 6 years ago

general: ugly extraction of Mac library from zipped bundle, refs #74

Revision 2a6a0554
Added by Radegast over 6 years ago

misc: script to generate ET 2.60b compatible bundle, refs #74

Revision 646aff39
Added by Radegast over 6 years ago

client: enabled localization support on Mac, refs #74

Revision ee04dd00
Added by Radegast over 6 years ago

general: removed support for ancient Macs, refs #50, refs #51, refs #52, refs #74

Revision a3021850
Added by Radegast over 6 years ago

client: fixed compilation with USE_OPENAL on Mac, refs #120, refs #74

Revision c201d23f
Added by Radegast over 6 years ago

general: new FS_Unzip function, refs #74

Revision 0ad22f70
Added by Radegast over 6 years ago

general: fixed Sys_OpenURL function on Mac, refs #74

Revision d4145c45
Added by Radegast over 6 years ago

client: minimize cmd results in black window on Mac, refs #74

Revision 2c73a6d4
Added by Radegast over 6 years ago

generic: made FS_Unzip and Sys_LoadDll less noisy, refs #74

Revision b496d562
Added by Radegast over 6 years ago

generic: forgotten MACOSX define, refs #74

Revision 7d0cee2d
Added by IR4T4 over 6 years ago

Mac version refs #74

Revision 302a157a
Added by Radegast over 6 years ago

general: removed Mac functions Sys_StripAppBundle, refs #74

Revision 3289e6de
Added by Radegast about 6 years ago

misc: build universal ui/cgame binary for i386 and x86_64 archs, refs #74

Revision 8374f5ef
Added by Radegast about 6 years ago

general: default fs_homepath set to ~/Library/Application Support on Mac OS X, refs #74

Revision 341d3ce4
Added by Radegast over 5 years ago

misc: enabled Omni-bot support for Mac OS X, refs #74

Revision 4d24f09a
Added by Zack Middleton over 5 years ago

generic: ignore -psn* arguments on Mac OS X, refs #74

Mac OS X adds an argument starting with "-psn" when launched using Finder, Dock,
or a terminal using open command and not specifying arguments.

It caused the opening videos to be skipped.

This change mimics SDL 1.2.

Revision a229750c
Added by Seth Willits over 5 years ago

generic: support building on OS X, refs #74

CMakeLists.txt
- etl is built as a .app bundle on OS X

easybuild.sh
- OS X by default does not bundle curl (no point)
- Because the client is built as a .app on OS X, the install directories are tweaked a bit

misc/Info.plist
- Updated to use the vars specified in CMakeLists.txt

src/sys_main.m
- Changes to handle dylibs instead of only just the old-school zipped .bundle packages on OS X
- main() was tweaked to set Sys_BinaryPath to the parent of the .app on OS X

History

#1 Updated by IR4T4 almost 7 years ago

  • Category set to General

#2 Updated by IR4T4 over 6 years ago

  • Target version changed from ALL to 2.70rc1

#3 Updated by morsik over 6 years ago

  • Tracker changed from Bug to Feature
  • Subject changed from Fix apple MAC support to Mac OS X Support
  • Status changed from New to In Progress
  • Priority changed from Normal to Low
  • % Done changed from 0 to 30

Initial OS X support added.

It’s HIGHLY EXPERIMENTAL and NOT TESTED.

  • BROKEN: mouse acceleration
  • NEEDFIX: original mod loading doesn’t works, because our code loads/compiles .dylib, but original code loads OS X Bundle package.
    We MUST change build to Bundle because of 2 reasons:
    - backward compatibility (;>)
    - .dylib in NOT unloadable... so we need Bundle anyway
  • NEEDFIX: idSqrt function was originally written for PowerPC i think...
  • not sure if sound works (it’s possible because we use SDL-builtin audio)

And some screenshot: http://wstaw.org/m/2012/09/23/Screen_shot_2012-09-23_at_2.18.08_PM.png
3D works OK, but i just started /devmap oasis to check if it loads correctly - nothing more.

#4 Updated by Radegast over 6 years ago

  • % Done changed from 30 to 40

CMake now compiles library bundle instead of dylib. To be compatible with ET 2.60b, however, we need to pack that bundle into an app bundle.

#5 Updated by IR4T4 over 6 years ago

idSqrt function enabled to fix BROKEN mouse acceleration ... however if we still have issues check q_shared.h - Q_fabs() see "#if idppc"

#6 Updated by Radegast over 6 years ago

IR4T4 wrote:

idSqrt function enabled to fix BROKEN mouse acceleration ... however if we still have issues check q_shared.h - Q_fabs() see "#if idppc"

As discussed on IRC, mouse acceleration is not broken without idSqrt (at least not on new Macs). Mac compilation now fails because of redefinition of this function.

#7 Updated by Radegast over 6 years ago

I wrote an ugly patch which loads the library from the app bundle. Good news is Silent mod works. Bad news is NoQuarter crashes:

Sys_LoadDll(/tmp/ui_mac): succeeded ...
Sys_LoadDll(ui) found vmMain function at 0x3a2e474c
ERROR: Could not open "sound/misc/menu2.wav" 

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000013
0x0007a614 in LAN_LoadCachedServers () at /Users/jansimek/Development/etlegacy/src/client/cl_ui.c:76
76        if (com_gameInfo.usesProfiles && cl_profile->string[0])

#8 Updated by IR4T4 over 6 years ago

I did revert the sqrt() change.

The crash looks more like an engine issue with the client profile. Let’s nail it down on IRC ...

#9 Updated by Radegast over 6 years ago

  • Priority changed from Low to Normal

Only those mods compiled with GCC 4.2 or earlier on Mac are compatible with ET:L. The reason is that Apple uses gcc-llvm with newer versions of GCC. I will create a separate ticket for that.

This turned out to be incorrect. IR4T4 added clang support and some (most) mods still crash.

#10 Updated by Radegast over 6 years ago

  • % Done changed from 40 to 50

Looks like only Silent mod works with ET:L on Mac.

It may have something to do with this:

$ file extracted/nq/ui_mac 
ui_mac: Mach-O universal binary with 2 architectures
ui_mac (for architecture ppc):    Mach-O bundle ppc
ui_mac (for architecture i386):    Mach-O bundle i386

$ file extracted/silent/ui_mac
ui_mac: Mach-O bundle i386

Loading NoQuarter 1.2.9:

Sound memory manager started
Sys_LoadDll(/Users/jansimek/.etwolf/nq/ui_mac)... 
Extracting library from bundle...
unzip -o -j /Users/jansimek/.etwolf/nq/ui_mac ui_mac.bundle/Contents/MacOS/ui_mac -d /tmp
Archive:  /Users/jansimek/.etwolf/nq/ui_mac
  inflating: /tmp/ui_mac             
Reading symbols for shared libraries . done
Sys_LoadDll(/tmp/ui_mac): succeeded ...
Sys_LoadDll(ui) found vmMain function at 0x3c2e474c
ERROR: Could not open "sound/misc/menu2.wav" 

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000013
0x00085a8a in LAN_LoadCachedServers () at cl_ui.c:76
76        if (com_gameInfo.usesProfiles && cl_profile->string[0])
(gdb) bt
#0  0x00085a8a in LAN_LoadCachedServers () at cl_ui.c:76
#1  0x00088b20 in CL_UISystemCalls (args=0xbfffe6c8) at cl_ui.c:1119
#2  0x0004986c in VM_DllSyscall (arg=88) at vm.c:341
#3  0x3c313c1a in trap_LAN_LoadCachedServers ()
#4  0x3c2fb89d in _UI_Init ()
#5  0x3c2e48b7 in vmMain ()
#6  0x0004a459 in VM_Call (vm=0x267be0, callnum=1) at vm.c:714
#7  0x00089c58 in CL_InitUI () at cl_ui.c:1352
#8  0x0007a3b7 in CL_StartHunkUsers () at cl_main.c:3270
#9  0x0001fa6a in Com_Init (commandLine=0xbfffe9b0 "") at common.c:3110

#11 Updated by Radegast over 6 years ago

This issue is most likely caused by universal binaries. When we compiled NoQuarter for i386 arch only, it loaded without any problems. Question is how to load universal binaries without crashing?

#12 Updated by IR4T4 over 6 years ago

see GPL Sys_LoadDll in mac_main.cpp

#13 Updated by Radegast over 6 years ago

IR4T4 wrote:

see GPL Sys_LoadDll in mac_main.cpp

Code in the tryMachO block results in exactly the same crash as our SDL code.
Code in the tryAppPackage block results in redirection to cantLoad block, because this line fails:

libString = CFStringCreateWithCString( kCFAllocatorDefault, name2, kCFStringEncodingUTF8 );

#14 Updated by Dragonji over 6 years ago

Maybe it’s time to discontinue PPC support?

#15 Updated by IR4T4 over 6 years ago

Radegast, this seems to be a known issue on MAC, entering "CFStringCreateWithCString kCFStringEncodingUTF8 crash" into google offered me some links ...

#16 Updated by IR4T4 over 6 years ago

  • Target version changed from 2.70rc1 to 2.75

#17 Updated by IR4T4 over 6 years ago

add the MAC OS environment to Sys_Dialog

#18 Updated by IR4T4 over 6 years ago

  • Target version changed from 2.75 to 2.71rc1

#19 Updated by Radegast over 6 years ago

  • Target version changed from 2.71rc1 to 2.71

#20 Updated by IR4T4 over 6 years ago

  • Priority changed from Normal to High

#21 Updated by Radegast over 6 years ago

__MACOS__ define for older Macs was removed in changeset ee04dd00. This was done to clean deprecated code as some functions like Sys_PumpEvents were not ported from 2.60b, so build on old Macs would fail anyway. A couple of things did not get set on Mac OS X correctly because of that __MACOS__ define, so that was fixed as well.

There is also a custom define MACOS_X, but we should start using the standard - __APPLE__.

#22 Updated by Radegast over 6 years ago

IR4T4: CPUSTRING is now set to MacOS_X in Mac build. Do mods like NoQuarter depend on the old CPUSTRING, i.e. OSX-universal?

#23 Updated by Radegast over 6 years ago

Tested mod loading with the new FS_Unzip function. Silent 0.6.1 loads normally, NoQuarter results in this segfault:

UI menu load time = 427 milli seconds
Cvar_Set2: ui_mousePitch 0
FS_Unzip: Creating directory /Users/jansimek/.etlwolf/nq/cgame_mac.bundle/...
FS_Unzip: Creating directory /Users/jansimek/.etlwolf/nq/cgame_mac.bundle/Contents/...
FS_Unzip: Extracting /Users/jansimek/.etlwolf/nq/cgame_mac.bundle/Contents/Info.plist...
FS_Unzip: Creating directory /Users/jansimek/.etlwolf/nq/cgame_mac.bundle/Contents/MacOS/...
FS_Unzip: Extracting /Users/jansimek/.etlwolf/nq/cgame_mac.bundle/Contents/MacOS/cgame_mac...
Sys_LoadDll(/Users/jansimek/.etlwolf/nq/cgame_mac.bundle/Contents/MacOS/cgame_mac)... 
tty]Reading symbols for shared libraries . done
Sys_LoadDll(/Users/jansimek/.etlwolf/nq/cgame_mac.bundle/Contents/MacOS/cgame_mac): succeeded ...
Sys_LoadDll(cgame) found vmMain function at 0x3f6fc2a0
Cvar_Set2: version 
Empty name passed to RE_RegisterSkin
tty]
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
0x00008109 in CM_TempBoxModel (mins=0x0, maxs=0xc00, capsule=1) at /Users/jansimek/Development/etlegacy/src/qcommon/cm_load.c:865
865        VectorCopy(mins, box_model.mins);

GDB bactrace:

(gdb) bt
#0  0x00008109 in CM_TempBoxModel (mins=0x0, maxs=0xc00, capsule=1) at /Users/jansimek/Development/etlegacy/src/qcommon/cm_load.c:865
#1  0x00069eae in CL_CgameSystemCalls (args=0xbfff5e68) at /Users/jansimek/Development/etlegacy/src/client/cl_cgame.c:682
#2  0x0004faee in VM_DllSyscall (arg=32) at /Users/jansimek/Development/etlegacy/src/qcommon/vm.c:341
#3  0x3f0431e7 in trap_R_SetColor ()
#4  0x3f703db9 in CG_Init ()
#5  0x3f6fc473 in vmMain ()
#6  0x000507dd in VM_Call (vm=0x24bb68, callnum=0) at /Users/jansimek/Development/etlegacy/src/qcommon/vm.c:704
#7  0x0006d239 in CL_InitCGame () at /Users/jansimek/Development/etlegacy/src/client/cl_cgame.c:1185
#8  0x00081b48 in CL_DownloadsComplete () at /Users/jansimek/Development/etlegacy/src/client/cl_main.c:1917
#9  0x000821b1 in CL_InitDownloads () at /Users/jansimek/Development/etlegacy/src/client/cl_main.c:2074
#10 0x0008f375 in CL_ParseGamestate (msg=0xbfff6850) at /Users/jansimek/Development/etlegacy/src/client/cl_parse.c:766
#11 0x0008ffa4 in CL_ParseServerMessage (msg=0xbfff6850) at /Users/jansimek/Development/etlegacy/src/client/cl_parse.c:1066
#12 0x00084a86 in CL_PacketEvent (from={type = NA_IP, ip = "\005?\033\v", ip6 = "??????\025\000\000x?\004\006\000\000", port = 14445, scope_id = 1431979}, msg=0xbfff6850) at /Users/jansimek/Development/etlegacy/src/client/cl_main.c:2654
#13 0x0001ffde in Com_EventLoop () at /Users/jansimek/Development/etlegacy/src/qcommon/common.c:2529
#14 0x00021c5a in Com_Frame () at /Users/jansimek/Development/etlegacy/src/qcommon/common.c:3310
#15 0x000b057b in SDL_main (argc=9, argv=0x2750630) at /Users/jansimek/Development/etlegacy/src/sys/sys_main.c:728
#16 0x0012440f in -[SDLMain applicationDidFinishLaunching:] ()
#17 0x99dfcc52 in __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_0 ()
#18 0x94ab2e01 in ___CFXNotificationPost_block_invoke_0 ()
#19 0x949fe43a in _CFXNotificationPost ()
#20 0x99de5788 in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#21 0x97f6918e in -[NSApplication _postDidFinishNotification] ()
#22 0x97f68e48 in -[NSApplication _sendFinishLaunchingNotification] ()
#23 0x97f65d9f in -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:] ()
#24 0x97f658b4 in -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] ()
#25 0x917b3628 in -[NSObject performSelector:withObject:withObject:] ()
#26 0x99e0023a in __76-[NSAppleEventManager setEventHandler:andSelector:forEventClass:andEventID:]_block_invoke_0 ()
#27 0x99dffd91 in -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] ()
#28 0x99dffb8e in _NSAppleEventManagerGenericHandler ()
#29 0x9a366535 in aeDispatchAppleEvent ()
#30 0x9a33c9de in dispatchEventAndSendReply ()
#31 0x9a33c89d in aeProcessAppleEvent ()
#32 0x94e05e48 in AEProcessAppleEvent ()
#33 0x97f61ddd in _DPSNextEvent ()
#34 0x97f6126c in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#35 0x97f576cc in -[NSApplication run] ()
#36 0x0012420d in CustomApplicationMain ()
#37 0x001246f4 in main ()
Current language:  auto; currently minimal

#24 Updated by Radegast over 6 years ago

I managed to replace ET:L Sys_LoadDll function with the one from W:ET GPL and now I am able to connect to ETPub and NoQuarter servers, but I’m immediately kicked by this:

SV_DropClient(cl, "Unpure client detected. Invalid .PK3 files referenced!");

#25 Updated by IR4T4 over 6 years ago

@Radegast: Worth to have a look at the macros in "intptr_t QDECL VM_DllSyscall(intptr_t arg, ...)" ... I can’t see our apple just powerpc

#26 Updated by Radegast over 6 years ago

I think I was wrong about the cause of Mac OS X incompatibility. I am able to connect to Jaymod 2.2 servers and their mod libs contain PPC binaries:

~/.etlwolf/jaymod$ file ui_mac.bundle/Contents/MacOS/ui_mac 
ui_mac.bundle/Contents/MacOS/ui_mac: Mach-O universal binary with 2 architectures
ui_mac.bundle/Contents/MacOS/ui_mac (for architecture i386):    Mach-O bundle i386
ui_mac.bundle/Contents/MacOS/ui_mac (for architecture ppc):    Mach-O bundle ppc

#27 Updated by boutetnico over 6 years ago

I’m unable to load ETrun server module (qagame_mac) bundle version with ET: Legacy built from git repository whereas it works with ET 2.60d OSX.

The issue comes from Sys_TryLibraryLoad function from sys_main.c. When my bundle gets unziped with FS_Unzip(fn, qtrue), the extracted content is put in a subfolder named with the mod name (etrun in my case).

So the module (qagame_mac) gets extracted in:

$homepath/etrun/etrun/qagame_mac.bundle/Contents/MacOS/

The problem is Sys_TryLibraryLoad is making an incorrect path to find the qagame_mac module:

Com_sprintf(buffer, sizeof(buffer), "%s/%s.bundle/Contents/MacOS/%s", gamedir, fname, fname);

There is a missing "etrun/" after $homepath.

My workaround is:

Com_sprintf(buffer, sizeof(buffer), "%s/%s.bundle/Contents/MacOS/%s", gamedir, fname, fname);

I haven’t tested other mods but as my bundle gets loaded fine in ET 2.60d OSX I guess there is an issue.

#28 Updated by IR4T4 over 6 years ago

  • Assignee set to Radegast

#29 Updated by Radegast over 6 years ago

boutetnico: could you upload ETRun mac server bins here or give us a link to them? I haven’t tested Mac ET:L server with any mods besides Legacy, but ui and cgame libs from Jaymod and Silent mod load from this path ""%s/%s.bundle/Contents/MacOS/%s", gamedir, fname, fname" successfully.

Also, you don’t have to zip mac bins. You can just name them ui_mac, cgame_mac and qagame_mac and they will be loaded directly without unpacking.

#30 Updated by boutetnico about 6 years ago

Radegast wrote:

boutetnico: could you upload ETRun mac server bins here or give us a link to them?

If you need it: http://etrun.timeruns.net/ETrun-1.0.1.zip

I haven’t tested Mac ET:L server with any mods besides Legacy, but ui and cgame libs from Jaymod and Silent mod load from this path ""%s/%s.bundle/Contents/MacOS/%s", gamedir, fname, fname" successfully.

Also, you don’t have to zip mac bins. You can just name them ui_mac, cgame_mac and qagame_mac and they will be loaded directly without unpacking.

After some research, I figured out that my bundle wasn’t properly made, there was an extra etrun/ folder, so that’s why ET: Legacy wasn’t able to load it. I removed the extra etrun/ folder and now it works. (out of topic: the problem now is ET 2.60d is no longer able to load my mod bundles..., so I can’t have one bundle that will both work with ET 2.60d and ET: Legacy.)

#31 Updated by Radegast about 6 years ago

boutetnico: I will fix ETRun loading in 2.71rc2

#32 Updated by Dragonji about 6 years ago

  • Subject changed from Mac OS X Support to OS X support
  • Description updated (diff)

#33 Updated by IR4T4 over 5 years ago

  • Subject changed from OS X support to OS X support - make ETL apple client mod compatible

#34 Updated by Radegast over 5 years ago

  • Description updated (diff)
  • Target version changed from 2.71 to 2.78

I managed to make ET:L app bundle for Mac OS X 10.9 Mavericks.

http://mirror.etlegacy.com/etlegacy-2.71rc3-dirty-git.zip

Just unzip and click on etl.app

If that doesn’t work, you need to download libSDL 1.2 DMG file from http://libsdl.org/download-1.2.php, open it and move "SDL.framework" to /Library/Frameworks or /Users/username/Library/Frameworks

Please report if that works for you.

#35 Updated by Radegast over 5 years ago

  • Follows Bug #462: Don't use hardcoded Application Support path on Mac added

#36 Updated by Radegast almost 5 years ago

  • Status changed from In Progress to Fixed
  • Target version changed from 2.78 to 2.71rc4
  • % Done changed from 50 to 100
  • OS set to OS X

The old mods will never be compatible with ET:L on OS X unless they are recompiled and we can’t do anything about that.

#37 Updated by s1l3nce over 4 years ago

Update
ET:L works on both OS X 10.9 and 10.10 Yosimite with Silentmod and ETRun.
NoQuarter is not working and someone needs to recompile it for us or perhaps create a special bundle. That would be awesome.
I couldn’t get bots to work with the built in Omnibot but maybe someone can post a tutorial for this?

#38 Updated by Radegast over 4 years ago

Omni-bot doesn’t support OS X unfortunately (it also doesn’t support 64bit arch).

Also available in: Atom PDF