Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/honghaoz/calayerdrawcontext-issue-ventura
CALayerDrawContext Issue on Ventura (CGBitmapContextGetWidth: invalid context 0x600003876e80)
https://github.com/honghaoz/calayerdrawcontext-issue-ventura
Last synced: about 1 month ago
JSON representation
CALayerDrawContext Issue on Ventura (CGBitmapContextGetWidth: invalid context 0x600003876e80)
- Host: GitHub
- URL: https://github.com/honghaoz/calayerdrawcontext-issue-ventura
- Owner: honghaoz
- Created: 2023-06-29T03:45:39.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-06-29T03:51:08.000Z (over 1 year ago)
- Last Synced: 2023-07-31T15:46:51.797Z (over 1 year ago)
- Language: Swift
- Size: 27.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CALayerDrawContext-Issue-Ventura
`CALayer` invalid CGContext on Ventura `(CGBitmapContextGetWidth: invalid context 0x600003876e80)`The following code runs well on macOS Monteray but broken on macOS Ventura (tested on `13.3.1` and `13.4.1`)
```swift
import Cocoaclass ViewController: NSViewController {
class TestLayer: CALayer {
override func draw(in ctx: CGContext) {
super.draw(in: ctx)
print("context.width: \(ctx.width))")
print("context.width: \(ctx.height))")
print("context: \(ctx))")
}
}private let testLayer = TestLayer()
override func viewDidLoad() {
super.viewDidLoad()view.wantsLayer = true
view.layer?.backgroundColor = NSColor.red.cgColortestLayer.frame = CGRect(x: 0, y: 0, width: 100, height: 100)
view.layer?.addSublayer(testLayer)
}override func viewDidAppear() {
testLayer.setNeedsDisplay()
}override var representedObject: Any? {
didSet {
// Update the view, if already loaded.
}
}
}
```The error message:
```
2023-06-28 20:47:56.423328-0700 CALayerDrawContext[68964:1640092] [demo.CALayerDrawContext.CALayerDrawContext] CGBitmapContextGetWidth: invalid context 0x6000039dea00. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
context.width: 0)
2023-06-28 20:47:56.423407-0700 CALayerDrawContext[68964:1640092] [demo.CALayerDrawContext.CALayerDrawContext] CGBitmapContextGetHeight: invalid context 0x6000039dea00. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
context.width: 0)
context: (kCGContextTypeCoreAnimationAutomatic))
```