Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » OS X 10.4 (Tiger) and Grabber v4.2.0 Beta 3

This thread is locked; no one can reply to it. rss feed Print
 1   2 
OS X 10.4 (Tiger) and Grabber v4.2.0 Beta 3
Ultio
Member #1,336
April 2001

I recently upgraded Allegro on my Mac to v4.2.0 Beta 3. The compile went fine, with occasional warnings here and there. I'm able to compile and run my game fine, with no real issues. My problem is with Grabber. While trying to update one of my datafiles, Grabber put me into the "spinning pinwheel of death" mode while saving. My datafile is now destroyed (nothing to cry over, I have backups). What I find interesting, though, is how the grabber dies.

When I run grabber in windowed mode, it can die on loading and/or saving a prexisting datafile. It can also die when simply starting up. The program loads, I get a window with a black screen, and then the allegro gui never displays.

Doing the same operations while running in full screen mode, however, I don't see any of the same issues.

At first I thought it might be because it's trying to run in some color depth that OSX might not like in windowed mode (my PowerBook is picky and prefers 15bit to 16bit when running in a window). That wasn't it either. It just appears that Grabber locks up and "pinwheels" for eternity when running in windowed mode.

Another thing I noticed is that the mouse cursor is all screwed up. Most of the time it's fine, but sometimes it decides that the actual position of the mouse pointer and the mouse cursor should no longer point to the same place. For instance, I will have my mouse cursor clearly over the file menu, but the object menu is blackened (as if I'm hovering over it).

Can anyone else running the latest OSX/Allegro verify this for me?
I'm running it from the terminal, issuing the -windowed switch.

[Edit:] By the way, if it offers any help: Previous to this I was running Allegro 4.1.15. I would run grabber in windowed mode for all of my datafile editing and never once encountered this pseudo-hanging issue.

[Edit 2]: Some more additional info. I ran it (non debug mode version) through GDB and got some information for a session where it was stuck trying to load (it shows a black screen and the Allegro gui has yet to appear)

1(gdb) bt
2#0 0x9002ca98 in semaphore_wait_signal_trap ()
3#1 0x90001c2c in pthread_mutex_lock ()
4#2 0x300c0294 in osx_update_dirty_lines ()
5#3 0x000229c0 in ?? ()
6#4 0x9287bbf8 in _nsnote_callback ()
7#5 0x90771840 in __CFXNotificationPost ()
8#6 0x90769964 in _CFXNotificationPostNotification ()
9#7 0x92866000 in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
10#8 0x9361f620 in -[NSApplication _postDidFinishNotification] ()
11#9 0x9361f50c in -[NSApplication _sendFinishLaunchingNotification] ()
12#10 0x9361f054 in -[NSApplication(NSAppleEventHandling) _handleAEOpen:] ()
13#11 0x9361ebfc in -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] ()
14#12 0x9287cc04 in -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] ()
15#13 0x9287ca64 in _NSAppleEventManagerGenericHandler ()
16#14 0x91450a40 in aeDispatchAppleEvent ()
17#15 0x914508dc in dispatchEventAndSendReply ()
18#16 0x91450734 in aeProcessAppleEvent ()
19#17 0x931253e4 in AEProcessAppleEvent ()
20#18 0x9361d344 in _DPSNextEvent ()
21#19 0x9361ce68 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] ()
22#20 0x936193cc in -[NSApplication run] ()
23#21 0x00022e68 in ?? ()
24#22 0x00008a5c in ?? ()
25#23 0x000088fc in ?? ()
26(gdb) info threads
27 6 process 3332 thread 0xb903 0x9002ca98 in semaphore_wait_signal_trap ()
28 5 process 3332 thread 0x7407 0x90056418 in semaphore_timedwait_signal_trap ()
29 4 process 3332 thread 0x6d13 0x9000a778 in mach_msg_trap ()
30 3 process 3332 thread 0x3f07 0x9001efec in select ()
31 2 process 3332 thread 0x3d03 0x9002ca98 in semaphore_wait_signal_trap ()
32* 1 process 3332 local thread 0x6007 0x9002ca98 in semaphore_wait_signal_trap ()
33(gdb)

[Edit 3]: I compiled the debugging version. Using GDB I was able to gather some nice information from the thread that all of the good Allegro stuff runs in:

(gdb) thread 2
[Switching to thread 2 (process 5487 thread 0x3d03)]
#0  0x9002ca98 in semaphore_wait_signal_trap ()
(gdb) bt
#0  0x9002ca98 in semaphore_wait_signal_trap ()
#1  0x90001c2c in pthread_mutex_lock ()
#2  0x300dad20 in osx_mouse_set_sprite (sprite=0x380590, x=1, y=1) at src/macosx/qzmouse.m:347
#3  0x30074f50 in show_mouse (bmp=0x181aa00) at src/mouse.c:633
#4  0x30047e18 in do_dialog (dialog=0x2cc28, focus_obj=48) at src/gui.c:797
#5  0x00010f68 in _mangled_main (argc=2, argv=0xbffffcac) at tools/grabber.c:3868
#6  0x000260e4 in +[AllegroAppDelegate app_main:] (self=0x390c0, _cmd=0x2a924, arg=0x0) at src/macosx/main.m:168
#7  0x9287c2b4 in forkThreadForFunction ()
#8  0x9002c3d4 in _pthread_body ()
(gdb)

---
"It's nice knowing that someday, the software I write will just be pirated by millions of people." :-/
http://loomsoft.net | Zep's Dreamland | Allegro Newbie Tutorials

Peter Wang
Member #23
April 2000

Ultio, how reproducable is the problem with grabber? Do you mind checking with 4.2.0 beta 2? If you have CVS you could try to do a binary search to locate the exact patch that caused the bug.

Evert, I think we might need to push RC1 back a bit.

Ultio
Member #1,336
April 2001

I guess it depends on what operation you're doing. I never was able to get it to not crash when saving a slightly large datafile. With loading a datafile, and loading up the program initially, I'd say it's reproducible to ~ < 10 runs. As for binary searching for patches with CVS: I have no idea how to do that. I'm not very familiar with CVS at all.

Allegro 4.2.0 Beta 2 is the one that doesn't compile correctly for OSX without modification:

gcc -DALLEGRO_SRC -DALLEGRO_LIB_BUILD -Wall -Wno-unused -Wno-long-double  -O2 -funroll-loops -ffast-math -fomit-frame-pointer -fno-common -pipe -dynamic -DALLEGRO_USE_C -I. -I./include -o obj/macosx/alleg/gui.o -c src/gui.c
src/gui.c: In function 'update_menu':
src/gui.c:1816: error: invalid storage class for function 'shutdown_single_menu'

I'll have to look up some instructions on how to fix this problem. If I remember correctly, Thomas Harte has a fix lingering around on the forums somewhere. [Edit]: Found the thread in case anyone else might want to test this out, as well: [url http://www.allegro.cc/forums/view_thread.php?_id=486790]

One thing I noticed while building was that it was complaining that plugin(s).h did not exist in obj/macosx. I did a diff of 4.1.15 and 4.2.0 Beta 3 and noticed there were no differences, so I just made a copy of the file and the compile completed fine.

[Edit 2]: I have confirmed that this issue exists in Allegro 4.2.0 Beta 2 as well. In my initial bunch of runs I was able to get it to hang on load on the third try. I then proceeded to double test 4.1.15. It had no problems. I then decided that maybe I had read the version incorrectly in the Grabber's help tool, so I went to load it (4.2.0 Beta 2) once again, through gdb. On the first try I got the hanging issue. The mouse focus issue still exists as well, but I think this is a problem with scrolling the mouse off of the window's focus and then back into the window's focus.

The issue was apparently introduced between versions 4.1.15 and 4.2.0 Beta 2.

If you can offer me some guidance on how to do binary searching via CVS I'd be glad to help debug this problem further.

---
"It's nice knowing that someday, the software I write will just be pirated by millions of people." :-/
http://loomsoft.net | Zep's Dreamland | Allegro Newbie Tutorials

Peter Wang
Member #23
April 2000

As I remember, that particular problem in gui.c could be fixed just by moving the function prototype from inside a function block to outside.

If you're not familiar with CVS, maybe the easiest thing to do would be to grab different versions of the relevant files from here: http://cvs.sourceforge.net/viewcvs.py/alleg/allegro/. My guesses as to the relevant files would be src/gui.c and src/timer.c.

EDIT: Too late. Anyway, if it problem is in beta 2 as well then it's probably not what I thought. I don't have time to explain CVS, but if you have the bandwidth/patience, you could just try each release in turn to see roughly when the problem was introduced.

Ultio
Member #1,336
April 2001

I'm afraid, now, that I might have been building Grabber, but it was not using the correct dynamic libraries. For instance, I was building grabber, but not installing the Allegro library for that particular build. Is this the correct way of going about this process? I'm not sure. In the help menu for the Grabber it reported the correct version of Allegro. I'm not sure if this is something that is determined dynamically, or is stuck in there at compile time. The reason I bring up this issue is the following: after building 4.1.18 I got some errors when loading into GDB; mainly:

Reading symbols for shared libraries . done
dyld: lazy symbol binding failed: Symbol not found: __get_allegro_version
  Referenced from: /Current Project/allegro_development/allegro-4-1-18/tools/grabber
  Expected in: /usr/local/lib/liballeg-4.1.dylib

dyld: Symbol not found: __get_allegro_version
  Referenced from: /Current Project/allegro_development/allegro-4-1-18/tools/grabber
  Expected in: /usr/local/lib/liballeg-4.1.dylib

liballeg-4.1.dylib is just a symlink to my (working) 4.1.15 version of the library.

[Edit]: I played around with the symlink and made it point to my local version of the 4.1.18 library. Bingo, the error still occurs. When I built 4.1.18 I had to, again, make a copy of the plugins.h file (from 4.1.15) and put it into the ./obj/macosx directory. I had to make the other simple changes to src/gui.c and src/sound.c (the static issue).

It appears, now, that this bug was introduced between 4.1.15 and 4.1.18. I did even more sanity checking to make sure that 4.1.15 doesn't create this problem (multiple loads into gdb). I still can't get it to happen under 4.1.15. (By the way, all of my Allegro development under OSX has mostly been done with 4.1.15--which includes using the grabber tool on a daily basis. In all of that time, I've never had it lock up on me).

[Edit 2]: Ok. So, just to ensure I haven't been doing things wrong, I re-set up my symlinks (in /usr/local/lib) to explicitly point to the libraries I wanted them to point to (the working versions that I had just built) I was still able to get Beta 2 to crash, as well as 4.1.18. Talking with a fellow developer in #allegro, they were unable to get grabber to crash running 4.1.18 [Their system: G4 running OSX v10.3]. [Sub edit: upon further inspection I noticed the symlink: liballeg.dylib, which basically points to the latest version of the allegro library (beta 3 in my case). I'm not sure if this symlink really affects anything, as I'm able to run my 4.1.15 version of the grabber with no sideaffects. Oh, the library madness)].

I'm fairly new to helping out with Allegro development, so any general pointers will be much appreciated. For instance, is there some preferred method to ensure that your executable is running the proper library, etc, etc? I'd really be disappointed if this issue was something between beta3 and beta2 and my lack of knowledge in this kind of thing led me on a wild goose chase. :)

I'm done debugging this issue for tonight. Hopefully over the weekend I'll be able to provide some more information if you need any additional testing done. Also, by that time, someone else with a Mac (possibly running Tiger) will have been able to test this issue out.

---
"It's nice knowing that someday, the software I write will just be pirated by millions of people." :-/
http://loomsoft.net | Zep's Dreamland | Allegro Newbie Tutorials

Peter Wang
Member #23
April 2000

Quote:

In the help menu for the Grabber it reported the correct version of Allegro.

That version is the version you compiled against, not necessarily the version that is being run against.

The best way to go about testing multiple versions is to statically link. I assume on MacOS X this will work: make STATICLINK=1 (the docs/build/macosx.txt suggests so) For debugging modes you would do: make STATICLINK=1 DEBUGMODE=1

To make sure the grabber binary is not dynamically linked, in Linux I would type: ldd tools/grabber . Maybe Macs have `ldd' as well?

Evert
Member #794
November 2000
avatar

Quote:

Evert, I think we might need to push RC1 back a bit.

Yes, this definitely qualifies as a show-stopper.

Quote:

I was building grabber, but not installing the Allegro library for that particular build. Is this the correct way of going about this process?

Depends. Generally not, but it should be fine if you staticlink. Note that something compared against Allegro 4.2 should not even start if you only have a 4.1.x dynamic library lying around.

Quote:

I played around with the symlink and made it point to my local version of the 4.1.18 library. Bingo, the error still occurs.

This is actually not the proper way to test this. Allegro 4.1 libraries are not ABI compatible, so you can't just substitute 4.1.18 for 4.1.15 and expect it to work. You need to recompile and relink your programme.
In cases like this, I would (in Linux) build a static version of the library without modules to make sure I'm using what I think I'm using. I don't know how to do the same under MacOS X, or even if it's possible at all (see the readme file though, it should be documented there).

Quote:

I noticed the symlink: liballeg.dylib

Eek! My guess is that that should include a version number in the name somewhere (because different versions of the library are incompatible). This is a problem with the MacOS X build/install system we need to fix, I think.

Quote:

I'm fairly new to helping out with Allegro development, so any general pointers will be much appreciated.

You're doing fine so far. :)

Quote:

For instance, is there some preferred method to ensure that your executable is running the proper library, etc, etc?

As I said, I would staticlink under Linux, probably under Windows too. I'm not sure how to do that under MacOS X though.
The best alternative I can think of is to run `make uninstall' for the version you currently have installed (check that it's gone) and then run `make install' for the new version.

Ultio
Member #1,336
April 2001

Thanks, guys. I had a feeling I was going to be told to just use the statically linked version of the library. In my case, I'd rather not go uninstalling versions of Allegro that I've installed (and had work flawlessy), because I have projects that depend on them. For instance, the Mac port of ZD was build with 4.1.13 I believe; and I'd rather not blow that way, just in case I might need it for something. Most likely I'd be able to compile it with the latest and greatest; but something could possibly come up. I guess I could just suck it up, though, since I could grab whatever version I want from CVS anyways. :P

As far as I know, statically linking is as easy as how Peter described it. I don't see why that wouldn't work. In regards to using the ldd tool: I'm sure that OSX has it. I don't have my machine with me right now for testing, but I'll check it out over the weekend.

In fact, in regards to this whole issue: I can do some retesting of different revisions of Allegro with a statically linked build and see if I can produce any new results. I am hoping that through retesting I can find that something has broken between Beta 2, and Beta 3; which would be really nice; better than all the way back to 4.1.15.

I will keep in touch via this thread about any progress I am able to make. More than likely I won't be able to touch this issue until some time tomorrow.

---
"It's nice knowing that someday, the software I write will just be pirated by millions of people." :-/
http://loomsoft.net | Zep's Dreamland | Allegro Newbie Tutorials

Evert
Member #794
November 2000
avatar

Quote:

I had a feeling I was going to be told to just use the statically linked version of the library. In my case, I'd rather not go uninstalling versions of Allegro that I've installed (and had work flawlessy), because I have projects that depend on them.

Just keep the source tree in tact, you'll be able to rerun make install from there.

Quote:

I am hoping that through retesting I can find that something has broken between Beta 2, and Beta 3; which would be really nice; better than all the way back to 4.1.15.

If it is between 4.1.15 and 4.2 beta2, then please try to narrow it down further, say between 4.1.16 and 4.1.17.

Quote:

I will keep in touch via this thread about any progress I am able to make. More than likely I won't be able to touch this issue until some time tomorrow.

Take what time you need. I'll postpone the 4.2.0 RC1 until this is fixed, and it's more important that we get it right than that we rush the release out of the door.

Peter Hull
Member #1,136
March 2001

From Ultio's backtrace it looks like a deadlock is occurring for some reason. The OSX mouse code uses mutexes quite a lot whilst changing the mouse cursor etc.

From the list of versions that do and don't show this error, I wonder if it is about the same time as the hardware cursor stuff went in. The culprit files would be qzmouse.m and qzwindow.m.

Ultio, please could you check exmouse - does that show the same problem?

Some final things:
What Peter said about STATICLINK is correct - that's the way to do it.
I don't think I've ever seen this problem on 10.2, but I don't use the grabber a lot
I can't check right now, but IIRC liballeg.dylib is a symlink to the latest version, and liballeg-4.x.dylib is a symlink to the latest 4.x.y version. (it's almost the same on linux, too)

Pete

Matthew Leverton
Supreme Loser
January 1999
avatar

Quote:

In regards to using the ldd tool: I'm sure that OSX has it.

otool -L is the equivalent.

Evert
Member #794
November 2000
avatar

Bump to ask if there's been any progress so far?

Thomas Fjellstrom
Member #476
June 2000
avatar

Hmm. Should we not add a Function to grab the version of the running allegro? So we can compare the compiled version vs. the running version?

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Kitty Cat
Member #2,815
October 2002
avatar

Quote:

Hmm. Should we not add a Function to grab the version of the running allegro? So we can compare the compiled version vs. the running version?

You can, in a limited fashion. _get_allegro_version will return the version from the lib in hex. And starting at .17, the lib won't initialize if the library can be ABI incompatible (ie, between any two different WIP versions, or where the major and minor version doesn't match). It's internal, but it should be fine for testing here. As for a public function.. you'd probably have to make something else, since _get_allegro_version masks out the revision number on non-WIP branches.

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Peter Hull
Member #1,136
March 2001

Quote:

Bump to ask if there's been any progress so far?

I'm waiting for Ultio to report back about the static-link and also if exmouse shows the same problem. Otherwise there's not enough info to go on. I tried starting grabber via gdb about 20 times and did not see the problem, but that doesn't necessarily mean anything.

Pete

Ultio
Member #1,336
April 2001

Okay. I've started doing some more testing. My initial run was with a statically linked version of 4.1.18 (everything completely rebuilt). Unrelated to this, I noticed that when you do a make clean distclean and veryclean, the library in libs/macosx does not get removed.

Anyhow, I'm still able to get the grabber to crash under 4.1.18 static/debug linked. I'm going to be testing out some earlier versions. There are only two between 4.1.15 and 4.1.18 so it shouldn't take too long for me to write an update.

[Edit] Oookay. Under 4.1.17 it will either crash, or not crash and come up with a grey screen but no gui will appear--requiring a force quit. This is something I've never seen before. Now I'm getting really confused. ???

[Edit 2] Yahoo! Now I can rest knowing I'm not officially smoking crack. 4.1.16 works like a charm. No hangs on startup (tried about 20 or so times in a row), and no hangs loading/saving one of my larger datafiles.

I'm not so sure what's up with version 4.1.17 and not displaying the gui, but I guess that maybe we might try looking for differences between 4.1.16 and 4.1.17. Let me know if you guys need any more testing or information about this.

---
"It's nice knowing that someday, the software I write will just be pirated by millions of people." :-/
http://loomsoft.net | Zep's Dreamland | Allegro Newbie Tutorials

Peter Hull
Member #1,136
March 2001

So 4.1.16 is OK and 4.1.17 is not OK?

There were quite a few differences to the OSX code in that time-period.

Attached is the output of cvs diff -u -r v4-1-16 -r v4-1-17 src/macosx/

I'll look into it!

Pete

[edit]
OK, some progress but I'm really tired so I won't finish it today. Brain dump follows:
1. I have seen the problem that you describe, Ultio :-/ I got it 2 times out of 3 by starting gdb then 'wobbling' the terminal window around with the mouse, until the grabber window came up.
2. It looks like the problem might be with the mutexes osx_window_mutex and osx_event_mutex
From what I can see, show_mouse calls acquire_screen, which locks the window mutex. Then it calls gfx_driver->set_mouse_sprite.
osx_window_mutex arbitrates between the main thread which handles events and screen updates, and a secondary thread which is the actual Allegro app code (the grabber in this case). osx_event_mutex is something to do with events ( :P ) I think that set_mouse_sprite (in thread #2) is waiting on the event mutex, which won't get released because the main thread is waiting for the window mutex because it wants to update dirty lines.

What I am thinking is that the update dirty lines is not so critical - if it can't lock the mutex it should just continue, which would result in one frame dropped, but no deadlocks. I'll try this as an option - in the meantime I'd love to hear from any thread experts.

Night night!

Pete

Ultio
Member #1,336
April 2001

Quote:

So 4.1.16 is OK and 4.1.17 is not OK?

You are correct.

Quote:

It looks like the problem might be with the mutexes osx_window_mutex and osx_event_mutex

Yeah, from a GDB backtrace you can see that it's locked waiting for some semaphores. I didn't look into it much other than that, like you have.

It looks like you're going deeper than I have so far. Good luck with that. I might try looking at this stuff a bit tomorrow after I get out of work. :)

---
"It's nice knowing that someday, the software I write will just be pirated by millions of people." :-/
http://loomsoft.net | Zep's Dreamland | Allegro Newbie Tutorials

Peter Hull
Member #1,136
March 2001

OK, have a look at this code; it's the main event loop (thread #1)

while (1) {
      pthread_mutex_lock(&osx_event_mutex);
      osx_event_handler();
      if (osx_gfx_mode == OSX_GFX_WINDOW)
         osx_update_dirty_lines();
      else if (osx_gfx_mode == OSX_GFX_FULL) {
         if ((osx_palette) && (osx_palette_dirty)) {
            CGDisplaySetPalette(kCGDirectMainDisplay, osx_palette);
      osx_palette_dirty = FALSE;
   }
      }
      pthread_mutex_unlock(&osx_event_mutex);
      usleep(1000000 / refresh_rate);
   }

You can that, when osx_update_dirty_lines() is called, the osx_event_mutex is held. osx_update_dirty_lines locks the window mutex, does the update and unlocks it.
In the app itself (thread #2), the grabber calls acquire_screen, which holds the window mutex. It then does a set_mouse_sprite, which ends up in osx_set_mouse_sprite:

int osx_mouse_set_sprite(BITMAP *sprite, int x, int y)
{
...snip...
   pthread_mutex_lock(&osx_event_mutex);
   osx_cursor = requested_cursor = cursor;
   pthread_mutex_unlock(&osx_event_mutex);
   if (temp)
      destroy_bitmap(temp);

#undef GET_PIXEL_DATA
   return 0;
}

So, what can happen is that thread #1 holds the event mutex, thread #2 holds the window mutex, and neither can proceed without the other releasing the other mutex. Note also that the fullscreen code is different - that's why you don't see it in fullscreen.

Solutions: osx_update_dirty_lines can use pthread_mutex_trylock instead of pthread_mutex_lock. The problem is if the app is spending almost all of its time with the screen acquired, then osx_update_dirty lines will be
unlikely to obtain the window mutex, and, although the app will run, the screen won't update. A time-out on the lock might help - e.g try for 100ms and then give up.

Alternatively, I'm not sure why the event mutex needs to be held when osx_update_dirty_lines is called. Maybe these two can be separated, so thread #1 never needs to hold both at once.

I wonder if someone can check my logic on this, and I will prepare some patches for testing.

Pete

Elias
Member #358
May 2000

Good work finding this! I know from the X11 and windows ports how frustrating looking for locking problems can be :P

I don't know the OSX code at all, but I somehow don't like the trylock solution.. it means, updates will be missing. (And leave garbage on the screen?) But I may be wrong..

Maybe update_dirty_lines really doesn't need the event mutex? Then it would be easy to solve this by just calling it before the lock.

Else, the problem is simply, update_dirty_lines needs both mutexes. So, a standard informatics problem, how to deal with locking of two resources.

From what I remember, a simple way is to take care of the order. I.e., if all parts needing both mutexes always first lock one, then the other, there will be no problem. So make sure to always first acquire the window mutex, and then the event mutex (or the other way around). The problem here is, that at the event handler, first the event, then the window mutex is locked, and in the mouse code, first the window, then the event.

Another solution maybe would be an extra mutex, which is only used to lock the event handler, and the mouse updater.. so both lock out each other.

--
"Either help out or stop whining" - Evert

Ultio
Member #1,336
April 2001

Is the code for both thread 1 and thread 2 Allegro code? For one reason or another I was under the impression that the code for thread 1 was some OSX specific stuff that we didn't really have access to. Now that I look at it, though, it seems as if it's Allegro source that makes some calls to OSX native functions.

Care to share what files these are that you're looking at?

---
"It's nice knowing that someday, the software I write will just be pirated by millions of people." :-/
http://loomsoft.net | Zep's Dreamland | Allegro Newbie Tutorials

Elias
Member #358
May 2000

Quote:

Is the code for both thread 1 and thread 2 Allegro code?

All the threads are Allegro code.

--
"Either help out or stop whining" - Evert

Matthew Leverton
Supreme Loser
January 1999
avatar

I changed the code to this and the grabber hang problem went away, so it's definately the culprit:

1 while (1) {
2 pthread_mutex_lock(&osx_event_mutex);
3 osx_event_handler();
4 
5 if (osx_gfx_mode == OSX_GFX_WINDOW) {
6 pthread_mutex_unlock(&osx_event_mutex);
7 osx_update_dirty_lines();
8 }
9 else if (osx_gfx_mode == OSX_GFX_FULL) {
10 if ((osx_palette) && (osx_palette_dirty)) {
11 CGDisplaySetPalette(kCGDirectMainDisplay, osx_palette);
12 osx_palette_dirty = FALSE;
13 }
14 pthread_mutex_unlock(&osx_event_mutex);
15 }
16 else
17 pthread_mutex_unlock(&osx_event_mutex);
18
19 usleep(1000000 / refresh_rate);
20 }

Peter Hull
Member #1,136
March 2001

Ultio, in my code snippets above, the first was from main.m, the second from qzmouse.m

I've made two patches (attached) The first does pretty much what Matthew's does, i.e. it separates the dirty lines bit from the event mutex

1Index: src/macosx/main.m
2===================================================================
3RCS file: /cvsroot/alleg/allegro/src/macosx/main.m,v
4retrieving revision 1.24
5diff -u -r1.24 main.m
6--- src/macosx/main.m 12 Jun 2005 08:13:38 -0000 1.24
7+++ src/macosx/main.m 13 Jun 2005 17:25:17 -0000
8@@ -115,8 +115,6 @@
9 withObject: nil];
10
11 while (1) {
12- pthread_mutex_lock(&osx_event_mutex);
13- osx_event_handler();
14 if (osx_gfx_mode == OSX_GFX_WINDOW)
15 osx_update_dirty_lines();
16 else if (osx_gfx_mode == OSX_GFX_FULL) {
17@@ -125,6 +123,8 @@
18 osx_palette_dirty = FALSE;
19 }
20 }
21+ pthread_mutex_lock(&osx_event_mutex);
22+ osx_event_handler();
23 pthread_mutex_unlock(&osx_event_mutex);
24 usleep(1000000 / refresh_rate);
25 }

The second just uses trylock

1Index: src/macosx/qzwindow.m
2===================================================================
3RCS file: /cvsroot/alleg/allegro/src/macosx/qzwindow.m,v
4retrieving revision 1.18
5diff -u -r1.18 qzwindow.m
6--- src/macosx/qzwindow.m 1 May 2005 13:41:30 -0000 1.18
7+++ src/macosx/qzwindow.m 13 Jun 2005 16:50:48 -0000
8@@ -291,7 +291,7 @@
9 return;
10
11 /* Skip everything if there are no dirty lines */
12- pthread_mutex_lock(&osx_window_mutex);
13+ if (pthread_mutex_trylock(&osx_window_mutex)==0) {
14 for (rect.top = 0; (rect.top < gfx_quartz_window.h) && (!dirty_lines[rect.top]); rect.top++)
15 ;
16 if (rect.top >= gfx_quartz_window.h) {
17@@ -353,7 +353,7 @@
18 UnlockPortBits([qd_view qdPort]);
19 [qd_view unlockFocus];
20 pthread_mutex_unlock(&osx_window_mutex);
21-
22+ }
23 pthread_cond_broadcast(&vsync_cond);
24 }

IMO the first one is better, (or use Matthew's) for the reasons we discussed above.

I tested the demo game and it seemed to draw OK. Maybe, Ultio, you could try with ZD and see if there's any issues. I don't know if lillo still reads allegro.cc, but I could ask him about why the event mutex is locked when it is, in case there's something we're missing.

There are some slightly strange things in the event code, I might be able to improve performance a bit if I've got time...

Pete

Ultio
Member #1,336
April 2001

ZD was built with 4.1.13 I believe, and I haven't compiled it against anything new since then.

If nothing has changed in these files between 4.1.15 and 4.2.0 Beta 3 I can build a temporary version of allegro and link my current project against it. Currently it doesn't use any mouse related stuff but I can always toss some in just for the heck of it.

I'd suggest PMing lillo. I know he still pokes around from time to time. We could always try simply emailing him, as well.

---
"It's nice knowing that someday, the software I write will just be pirated by millions of people." :-/
http://loomsoft.net | Zep's Dreamland | Allegro Newbie Tutorials

 1   2 


Go to: