Skip to content

Fix build on current GNUstep and CALayer struct-property KVO crash#8

Open
pkgdemon wants to merge 2 commits into
gnustep:masterfrom
pkgdemon:master
Open

Fix build on current GNUstep and CALayer struct-property KVO crash#8
pkgdemon wants to merge 2 commits into
gnustep:masterfrom
pkgdemon:master

Conversation

@pkgdemon
Copy link
Copy Markdown

Summary

Two related changes so libs-quartzcore builds and the bundled demo
actually runs on current GNUstep/Linux:

  1. Build fixes so the headers and sources compile against the
    current generation of GNUstep core (Foundation/CoreFoundation) and
    against a non-Apple OpenGL.
  2. CALayer KVO fix: struct-typed animatable properties
    (bounds, position, anchorPoint, transform, sublayerTransform,
    contentsRect, shadowOffset) can no longer be registered for
    automatic KVO observation on GNUstep — the autogenerated setter
    overrides corrupt struct arguments passed by value through
    objc_msgSend. The demo app crashed on startup before this.

Build changes (da7275a)

  • Headers/QuartzCore/CABase.h — import Foundation/NSObject.h before
    CoreFoundation.h so CF inline functions can resolve -hash /
    -isEqual: signatures. (Same pattern libs-opal needs on current
    GNUstep.)
  • Headers/QuartzCore/CATransaction.h — switch from
    #import "CoreFoundation/CFDate.h" to
    #import <CoreFoundation/CoreFoundation.h>. The quoted per-header
    path doesn't resolve reliably against libs-corebase install layout.
  • Source/CABackingStore.h — move #define GL_GLEXT_PROTOTYPES 1
    outside the Apple-only block so non-Apple builds also get it, and
    add #import <GL/glext.h> for the non-Apple path.
  • Source/GNUmakefile / config.make — minor flag adjustments for
    the current toolchain.
  • .gitignore — ignore obj/, derived_src/, *.framework/,
    *.app/.

CALayer fix (2ae02bb)

CALayer -init used to register every property in its defaults list
for KVO observation via CAImplicitAnimationObserver. On GNUstep this
works for object-typed properties but breaks for struct-typed ones:
the KVO machinery generates a setter override that receives the struct
by value through objc_msgSend, and on GNUstep the argument marshalling
corrupts the struct contents. Setting bounds/position/etc. on a
fresh layer would then either crash or write garbage.

Changes in Source/CALayer.m:

  • Maintain a separate structKeys list: anchorPoint, transform,
    sublayerTransform, contentsRect, shadowOffset, bounds,
    position. These are excluded from addObserver:forKeyPath:.
    Their setters already emit willChange/didChange via
    GSCA_OBSERVABLE_SETTER / the manual -setBounds: / -setPosition:,
    so implicit animations still fire.
  • Add default-value handling for transform and sublayerTransform
    analogous to the existing shadowOffset special-case: try KVC first,
    fall back to the typed setter inside NS_DURING / NS_HANDLER.
  • Wrap the remaining (non-struct) addObserver: in NS_DURING / NS_HANDLER
    so property types that don't support automatic KVO (e.g. CGColorRef)
    don't abort -init.
  • Drop a dead #if 0 debug block.

Demo changes (2ae02bb)

  • Demo/AppController.m — remove the hand-rolled NSMenu creation
    under #if GNUSTEP. The main menu is already provided through the
    standard GNUstep app loading path; the duplicate menu setup was a
    leftover.
  • Rename GSQuartzCoreDemoQuartzCoreDemo in the Info.plist
    (ApplicationName, NSExecutable) to match the current bundle name.
  • Trailing whitespace fix in DemoOpenGLView.m.

Compatibility

  • macOS/Apple build path: unchanged; all CALayer.m changes are
    additive to the existing Apple code paths.
  • GNUstep with libs-corebase installed: header includes resolve
    through <CoreFoundation/CoreFoundation.h> as expected.

Testing

  • Built cleanly against current GNUstep core (libs-base, libs-gui,
    libs-corebase, libs-opal) on Devuan/Linux x86_64.
  • The bundled Demo/ QuartzCore demo launches, the CALayer tree is
    created without crashing, and the root layer renders through the
    GL view.

@pkgdemon pkgdemon requested a review from ivucica as a code owner April 23, 2026 01:43
@pkgdemon
Copy link
Copy Markdown
Author

Note this depends on gnustep/libs-opal#16

@pkgdemon
Copy link
Copy Markdown
Author

@gcasa Here are fixes discussed in last GNUstep meeting.

@pkgdemon
Copy link
Copy Markdown
Author

@ivucica Let me know if this is something you might want, or if you foresee the need for a lot of changes. I did get libs-opal fixes merged so this will build now.

@pkgdemon
Copy link
Copy Markdown
Author

@ivucica Also something else from the readme I am not sure this is the case anymore:

Patched Opal. Opal currently conflicts with AppKit. More specifically, it also implements an incompatible NSFont. An experimental patch is provided against r35173 of Opal in opal-nsfonthacks.patch.
Opal requires Cairo and may require corebase.

At least with my PR the demo app works fine, and no other patches required.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant