Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#51052 closed defect (fixed)

gtk3 @3.20.2 +quartz build error on Mac OS X 10.7

Reported by: McDutchie (Martijn Dekker) Owned by: dbevans (David B. Evans)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: mojca (Mojca Miklavec), fredowski
Port: gtk3

Description

gtk3 version 3.20.2 variant +quartz does not build on Mac OS X 10.7.5, apparently due to 'case' errors in gdkevents-quartz.c.

main.log attached.

Attachments (2)

main.log (179.4 KB) - added by McDutchie (Martijn Dekker) 3 years ago.
gtk3 @3.20.2 +quartz build failure on Mac OS X 10.7.5
patch-gdk_quartz_gdkevents-quartz-10_7_compat.diff (461 bytes) - added by mojca (Mojca Miklavec) 3 years ago.

Download all attachments as: .zip

Change History (23)

Changed 3 years ago by McDutchie (Martijn Dekker)

Attachment: main.log added

gtk3 @3.20.2 +quartz build failure on Mac OS X 10.7.5

comment:1 Changed 3 years ago by dbevans (David B. Evans)

Cc: devans@… openmaintainer@… removed
Owner: changed from macports-tickets@… to devans@…
Status: newassigned

Please don't CC openmainter (or nomaintainer) --they're not real addresses just indicators. Testing now to see if this is 10.7 specific or if I can reproduce your result on a more recent OS version.

comment:2 Changed 3 years ago by dbevans (David B. Evans)

The relevant error message from your log file are as follows

1771	:info:build gdkevents-quartz.c:982:10: error: use of undeclared identifier 'NSEventPhaseMayBegin'; did you mean 'NSEventPhaseBegan'?
1772	:info:build     case NSEventPhaseMayBegin:
1773	:info:build          ^~~~~~~~~~~~~~~~~~~~
1774	:info:build          NSEventPhaseBegan
1775	:info:build /System/Library/Frameworks/AppKit.framework/Headers/NSEvent.h:128:5: note: 'NSEventPhaseBegan' declared here
1776	:info:build     NSEventPhaseBegan       = 0x1 << 0,
1777	:info:build     ^
1778	:info:build gdkevents-quartz.c:982:10: error: duplicate case value 'NSEventPhaseBegan'
1779	:info:build     case NSEventPhaseMayBegin:
1780	:info:build          ^
1781	:info:build gdkevents-quartz.c:943:10: note: previous case defined here
1782	:info:build     case NSEventPhaseBegan:
1783	:info:build          ^
1784	:info:build 4 warnings and 2 errors generated.
1785	:info:build make[4]: *** [gdkevents-quartz.lo] Error 1
1786	:info:build make[4]: *** Waiting for unfinished jobs....
1787	:info:build 1 warning generated.

My testing shows gtk3 +quartz builds correctly on 10.8+. Unfortunately, I don't have a machine capable of running 10.7 to test that version so I have no way to verify your results.

However, according to Apple's Appkit Framework NSEvent Class Reference, the NSEventPhase* constants (including NSEventPhaseMayBegin) were introduced in 10.7 so this should build correctly on 10.7 although I would expect it to fail on 10.6 and earlier.

Questions:

  • Would you look in /System/Library/Frameworks/AppKit.framework/Headers/NSEvent.h and see if NSEventPhaseMayBegin is defined there? The definition should look something like
    #if MAC_OS_X_VERSION_10_7 <= MAC_OS_X_VERSION_MAX_ALLOWED
    enum {
        NSEventPhaseNone        = 0, // event not associated with a phase.
        NSEventPhaseBegan       = 0x1 << 0,
        NSEventPhaseStationary  = 0x1 << 1,
        NSEventPhaseChanged     = 0x1 << 2,
        NSEventPhaseEnded       = 0x1 << 3,
        NSEventPhaseCancelled   = 0x1 << 4,
        NSEventPhaseMayBegin    = 0x1 << 5,
    };
    #endif
    
  • What version of Xcode are you using? The recommended version for 10.7 is Xcode 4.6.3 which can be downloaded here.
Last edited 3 years ago by dbevans (David B. Evans) (previous) (diff)

comment:3 Changed 3 years ago by dbevans (David B. Evans)

To answer my own question, I downloaded a copy of Xcode 4.6.3 and I find that, in spite of the current documentation, the definition in NSEvent.h (included in the MacOSX10.7.sdk folder) does, in fact, leave out NSEventPhaseMayBegin

#if MAC_OS_X_VERSION_10_7 <= MAC_OS_X_VERSION_MAX_ALLOWED
enum {
    NSEventPhaseNone        = 0, // event not associated with a phase.
    NSEventPhaseBegan       = 0x1 << 0,
    NSEventPhaseStationary  = 0x1 << 1,
    NSEventPhaseChanged     = 0x1 << 2,
    NSEventPhaseEnded       = 0x1 << 3,
    NSEventPhaseCancelled   = 0x1 << 4,
};
#endif

so that's the problem. The definition from the MacOSX10.8.sdk folder (also included in this version of Xcode) does include it.

Last edited 3 years ago by dbevans (David B. Evans) (previous) (diff)

comment:4 in reply to:  2 Changed 3 years ago by McDutchie (Martijn Dekker)

Replying to devans@…:

  • Would you look in /System/Library/Frameworks/AppKit.framework/Headers/NSEvent.h and see if NSEventPhaseMayBegin is defined there?

Done. It is not.

  • What version of Xcode are you using? The recommended version for 10.7 is Xcode 4.6.3 which can be downloaded here.

I'm using Version 4.6.3 (4H1503).

comment:5 Changed 3 years ago by dbevans (David B. Evans)

Thanks, that agrees with my observations of the code.

Summarizing:

The failing code concerns support for touchpad pinch gestures (magnify, rotate) and requires the NSEventPhase API which according to the current documentation was added in 10.7. Accordingly the code enables this functionality for 10.7+ only. In reality, the NSEventPhaseMayBegin phase enum is not available in 10.7 but was only introduced in 10.8. Its absence is what is causing the 10.7 build error.

I have committed a patch in r147474 which enables this functionality for 10.8+ until the upstream developers can fix the code to work on 10.7 (without NSEventPhaseMayBegin).

This should allow gtk3 +quartz to build for you on 10.7 in the interim. Let me know whether or not this is the case. Thanks for your report.

comment:6 Changed 3 years ago by McDutchie (Martijn Dekker)

Confirmed, it builds fine now. Many thanks.

comment:7 Changed 3 years ago by mojca (Mojca Miklavec)

Cc: mojca@… added

Cc Me!

comment:8 Changed 3 years ago by mojca (Mojca Miklavec)

Cc: friedrich.beckmann@… added
Version: 2.3.4

I submitted a trivial patch to https://bugzilla.gnome.org/show_bug.cgi?id=760276 that ignores NSEventPhaseMayBegin (it could in principle also watch for '0x1 << 5') and lets GTK+ build on 10.7. What I don't know yet is how to test whether it behaves properly in different scenarios.

Changed 3 years ago by mojca (Mojca Miklavec)

comment:9 in reply to:  8 Changed 3 years ago by fredowski

Replying to mojca@…:

I submitted a trivial patch to https://bugzilla.gnome.org/show_bug.cgi?id=760276 that ignores NSEventPhaseMayBegin (it could in principle also watch for '0x1 << 5') and lets GTK+ build on 10.7. What I don't know yet is how to test whether it behaves properly in different scenarios.

Hi, thanks for putting me on cc and researching this topic. When I submitted the patch here: https://bugzilla.gnome.org/show_bug.cgi?id=760276 I only tested this on El Capitan (10.11). I do not have a test possibility for 10.7. However, to test the patch you can run:

gtk3-demo --run gestures

If gestures work, then you can zoom and rotate a square. I do this on a macbook via the trackpad.

The proposed patch looks good to me as the NSEventPhaseMayBegin event would anyway only cancel the process. During my tests I have not seen this Event.

Any feedback from testing this on 10.7 10.8 10.9 10.10 with the mentioned gtk3-demo is appreciated.

Friedrich

Last edited 3 years ago by fredowski (previous) (diff)

comment:10 Changed 3 years ago by mojca (Mojca Miklavec)

I will need some help with this:

> gtk3-demo --run gestures
2016-04-06 19:55:50.577 gtk3-demo[90281:2703] -deltaZ is deprecated for NSEventTypeMagnify.  Please use -magnification.
2016-04-06 19:55:50.618 gtk3-demo[90281:2703] *** Assertion failure in -[NSEvent phase], /SourceCache/AppKit/AppKit-1138.51/AppKit.subproj/NSEvent.m:2573
2016-04-06 19:55:50.620 gtk3-demo[90281:2703] An uncaught exception was raised
2016-04-06 19:55:50.622 gtk3-demo[90281:2703] Invalid message sent to event "NSEvent: type=Magnify loc=(204.844,230.066) time=145525.0 flags=0 win=0x7f9f1b2b23f0 winNum=19014 ctxt=0x0 deltaZ=0.999451 magnification=0.001999"
2016-04-06 19:55:50.721 gtk3-demo[90281:2703] (
	0   CoreFoundation                      0x00007fff94f33f56 __exceptionPreprocess + 198
	1   libobjc.A.dylib                     0x00007fff8f695d5e objc_exception_throw + 43
	2   CoreFoundation                      0x00007fff94f33d8a +[NSException raise:format:arguments:] + 106
	3   Foundation                          0x00007fff89ab571f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 169
	4   AppKit                              0x00007fff8c4857c5 -[NSEvent phase] + 185
	5   libgdk-3.0.dylib                    0x000000010b414d50 _gdk_quartz_display_queue_events + 3984
	6   libgdk-3.0.dylib                    0x000000010b41708f gdk_event_dispatch + 26
	7   libglib-2.0.0.dylib                 0x000000010ba02260 g_main_context_dispatch + 266
	8   libglib-2.0.0.dylib                 0x000000010ba0253f g_main_context_iterate + 409
	9   libglib-2.0.0.dylib                 0x000000010ba02597 g_main_context_iteration + 55
	10  libgio-2.0.0.dylib                  0x000000010b569fae g_application_run + 444
	11  gtk3-demo                           0x000000010abc4bae main + 325
	12  gtk3-demo                           0x000000010abab210 start + 52
	13  ???                                 0x0000000000000003 0x0 + 3
)
2016-04-06 19:55:50.723 gtk3-demo[90281:2703] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid message sent to event "NSEvent: type=Magnify loc=(204.844,230.066) time=145525.0 flags=0 win=0x7f9f1b2b23f0 winNum=19014 ctxt=0x0 deltaZ=0.999451 magnification=0.001999"'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff94f33f56 __exceptionPreprocess + 198
	1   libobjc.A.dylib                     0x00007fff8f695d5e objc_exception_throw + 43
	2   CoreFoundation                      0x00007fff94f33d8a +[NSException raise:format:arguments:] + 106
	3   Foundation                          0x00007fff89ab571f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 169
	4   AppKit                              0x00007fff8c4857c5 -[NSEvent phase] + 185
	5   libgdk-3.0.dylib                    0x000000010b414d50 _gdk_quartz_display_queue_events + 3984
	6   libgdk-3.0.dylib                    0x000000010b41708f gdk_event_dispatch + 26
	7   libglib-2.0.0.dylib                 0x000000010ba02260 g_main_context_dispatch + 266
	8   libglib-2.0.0.dylib                 0x000000010ba0253f g_main_context_iterate + 409
	9   libglib-2.0.0.dylib                 0x000000010ba02597 g_main_context_iteration + 55
	10  libgio-2.0.0.dylib                  0x000000010b569fae g_application_run + 444
	11  gtk3-demo                           0x000000010abc4bae main + 325
	12  gtk3-demo                           0x000000010abab210 start + 52
	13  ???                                 0x0000000000000003 0x0 + 3
)
terminate called throwing an exceptionAbort trap: 6

comment:11 Changed 3 years ago by fredowski

Does this mean that the magnification event cannot provide the phase property on 10.7?

comment:12 Changed 3 years ago by mojca (Mojca Miklavec)

I was trying to come up with a minimal Cocoa application to reproduce the problem and to be able to do further tests, but I never worked with Cocoa (beyond doing minimalistic changes to existing code) so I wasn't able to proceed as fast as I could (I need to go through tutorials first and yesterday even auto-generated hello world without any events crashed for me).

The problem is that Lion "fully supports" all those gestures and almost all the apps I use do. I would be motivated to spend some time getting it right. Maybe some of the functions were only added in 10.8. There is certainly a way to get it working on 10.7, but I need more time (or more experience or some helping hand to lead me a bit).

Friedrich, do you know how to create a very minimal Cocoa app that listens to mouse events?

comment:13 in reply to:  12 Changed 3 years ago by fredowski

Replying to mojca@…:

Friedrich, do you know how to create a very minimal Cocoa app that listens to mouse events?

Hi Mojca,

I am also not an experienced Apple programmer. But maybe you could follow the path that I walked... I take the gtk3 source tree from git. I have installed macports, so I do not need additional libraries - I just take the ones from macports. This only works with the version of gtk3 similar to the installed macports one because of the dependencies. Today this works on the gtk-3-20 branch. So I checkout the gtk-3-20 branch. Then I run the autogen.sh script for aclocal and friends. Then I run a new configure with

./configure --disable-x11-backend --enable-quartz-backend --enable-debug=yes LDFLAGS=-L/opt/local/lib CPPFLAGS=-I/opt/local/include --prefix=/Users/fritz/pspp/install

to use the macports libraries. Maybe the options could be given to autogen.sh already. Then I can do

make

make install

to install everything in my local directory given by --prefix

Then I can run

<prefix>/bin/gtk3-demo --run gestures

which is my application to handle the events. For inspection and debugging I added various printfs in gdkevents-quartz.c to see which events are generated by MacOS.

For example some printfs here: https://git.gnome.org/browse/gtk+/tree/gdk/quartz/gdkevents-quartz.c?h=gtk-3-20#n1419

This is how I did it.

Friedrich

Last edited 3 years ago by fredowski (previous) (diff)

comment:14 in reply to:  12 Changed 3 years ago by fredowski

Replying to mojca@…:

The problem is that Lion "fully supports" all those gestures and almost all the apps I use do. I would be motivated to spend some time getting it right. Maybe some of the functions were only added in 10.8. There is certainly a way to get it working on 10.7, but I need more time (or more experience or some helping hand to lead me a bit).

The problem is in my view the handling of gesture events in gtk. gtk expects to have a sequence of events in different phases like START, CHANGE, CHANGE, ..., CHANGE, END. This is on the gdk level. In wayland this event sequence is produced by the libinput library (I think). See https://wayland.freedesktop.org/libinput/doc/latest/gestures.html

However on MacOS the gestures were introduced without this phase idea firsthand. So you could get a single event telling you a Magnify or Rotate event. I had to use the phase information provided by the events to produce also the gdk required sequence of events. This phase concept was introduced later as we see.

Friedrich

comment:15 Changed 3 years ago by mojca (Mojca Miklavec)

I did some mouse event debugging some time ago and I clearly remember problems with so simple and stupid cases like scrolling or resizing a window.

With an old mouse wheel one would get huge discrete steps. With a trackpad on Mac one could get 20 or 50 events for what would be a "single move". In gnuplot with Qt backend this ends up as a completely useless feature because a graph with million or ten million points would be recalculated and redrawn 50 times just to change the window size and I remember that I didn't see any reasonable workaround back then without rewriting a lot of core gnuplot functionality. But maybe I should look again.

I have the following code in /System/Library/Frameworks/AppKit.framework/Versions/C/Headers/NSEvent.h

/* The phase of a gesture scroll event. A gesture phrase are all the events
   that begin with a NSEventPhaseBegan and end with either a NSEventPhaseEnded
   or NSEventPhaseCancelled. All the gesture events are sent to the view under
   the cursor when the NSEventPhaseBegan occurred.
   A gesture scroll event starts with a NSEventPhaseBegan phase and ends with
   a NSPhaseEnded. Legacy scroll wheel events (say from a Mighty Mouse)
   and momentum scroll wheel events have a phase of NSEventPhaseNone.
   Valid for NSScrollWheel
*/
- (NSEventPhase)phase NS_AVAILABLE_MAC(10_7);

So I don't believe that phase isn't known in 10.7.

Do you see any parameters that shouldn't be in this call?

Invalid message sent to event "NSEvent:
    type=Magnify
    loc=(204.844,230.066)
    time=145525.0
    flags=0
    win=0x7f9f1b2b23f0
    winNum=19014
    ctxt=0x0
    deltaZ=0.999451
    magnification=0.001999"

comment:16 Changed 3 years ago by mojca (Mojca Miklavec)

... or maybe the Magnify event indeed doesn't accept the phase. This needs more testing.

comment:17 in reply to:  16 Changed 3 years ago by fredowski

Replying to mojca@…:

... or maybe the Magnify event indeed doesn't accept the phase. This needs more testing.

This would be my guess. If you have 10.7 running, you could simply test it. If you would just trace the events and print the type, then the Magnify and Rotate events will result in a fill_pinch_event call which will call [nsevent phase]. I would now expect a crash once a Magnify or Rotate event will be called with phase property. Friedrich

comment:18 in reply to:  2 ; Changed 3 years ago by fredowski

Replying to devans@…:

My testing shows gtk3 +quartz builds correctly on 10.8+. Unfortunately, I don't have a machine capable of running 10.7 to test that version so I have no way to verify your results.

You seem to have 10.8 running. Could you try to test this functionally with

gtk3-demo --run gestures

?

Friedrich

comment:19 in reply to:  18 Changed 3 years ago by dbevans (David B. Evans)

Replying to friedrich.beckmann@…:

Replying to devans@…:

My testing shows gtk3 +quartz builds correctly on 10.8+. Unfortunately, I don't have a machine capable of running 10.7 to test that version so I have no way to verify your results.

You seem to have 10.8 running. Could you try to test this functionally with

gtk3-demo --run gestures

?

Well, I do have a machine running 10.8 but it's a Mac Mini and doesn't have a touch pad. So I guess I can't be much help, although it would be helpful to see if it works on 10.8+. Maybe some one else can do this.

Friedrich

comment:20 Changed 3 years ago by dbevans (David B. Evans)

Resolution: fixed
Status: assignedclosed

Since the patch that Friedrich submitted upstream (essentially the same as committed in r147474) has been committed here, I'm closing this ticket as fixed. The general conclusion seems to be that 10.7 doesn't fully support this functionality.

comment:21 Changed 3 years ago by mojca (Mojca Miklavec)

OK. I still believe that 10.7 should support these gestures, but I'll come back to you once I come up with a working patch.

Note: See TracTickets for help on using tickets.