MaddTheSane / Simple-Comic

macOS comic viewer
MIT License
261 stars 23 forks source link

Big Sur compatability #37

Closed ReverendKilljoy closed 4 years ago

ReverendKilljoy commented 4 years ago

MacBook Pro (15-inch, 2017); 2.9GHz Quad-core i7; 16GB RAM; Radeon Pro 560 4GB driving 2560 x 1080 in clamshell mode

OS 11.0 Beta (20A5343j)

The program crashes immediately on launch, crash report excerpt below:

System Integrity Protection: enabled

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_INSTRUCTION (SIGILL) Exception Codes: 0x0000000000000001, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY

Termination Signal: Illegal instruction: 4 Termination Reason: Namespace SIGNAL, Code 0x4 Terminating Process: exc handler [41040]

Application Specific Information: Attempt to pop an empty graphics context stack.

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 com.apple.AppKit 0x00007fff28d2f181 +[NSGraphicsContext _popGraphicsContext] + 203 1 com.apple.AppKit 0x00007fff28d2f0a1 +[NSGraphicsContext restoreGraphicsState] + 22 2 com.apple.AppKit 0x00007fff28e729ac -[NSView(NSLayerKitGlue) drawViewBackingLayer:inContext:drawingHandler:] + 1034 3 com.apple.QuartzCore 0x00007fff36502305 CABackingStoreUpdate + 190 4 com.apple.QuartzCore 0x00007fff365666d5 invocation function for block in CA::Layer::display_() + 53 5 com.apple.QuartzCore 0x00007fff36501848 -[CALayer _display] + 2183 6 com.apple.AppKit 0x00007fff28e724d4 -[_NSBackingLayer display] + 474 7 com.apple.AppKit 0x00007fff28dddecb -[_NSViewBackingLayer display] + 555 8 com.apple.QuartzCore 0x00007fff36500864 CA::Layer::display_if_needed(CA::Transaction) + 874 9 com.apple.QuartzCore 0x00007fff3663aba1 CA::Context::commit_transaction(CA::Transaction, double, double*) + 517 10 com.apple.QuartzCore 0x00007fff364de475 CA::Transaction::commit() + 783 11 com.apple.AppKit 0x00007fff28e876b8 62+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayLink]_blockinvoke + 266 12 com.apple.AppKit 0x00007fff295bdcdd NSRunLoopObserverCreateWithHandler_block_invoke + 41 13 com.apple.CoreFoundation 0x00007fff2be73816 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23 14 com.apple.CoreFoundation 0x00007fff2be736b3 CFRunLoopDoObservers + 549 15 com.apple.CoreFoundation 0x00007fff2be72b63 CFRunLoopRun + 838 16 com.apple.CoreFoundation 0x00007fff2be72134 CFRunLoopRunSpecific + 563 17 com.apple.HIToolbox 0x00007fff2a7c41d0 RunCurrentEventLoopInMode + 292 18 com.apple.HIToolbox 0x00007fff2a7c3e22 ReceiveNextEventCommon + 283 19 com.apple.HIToolbox 0x00007fff2a7c3cef _BlockUntilNextEventMatchingListInModeWithFilter + 64 20 com.apple.AppKit 0x00007fff28d026db _DPSNextEvent + 877 21 com.apple.AppKit 0x00007fff28d00f09 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1352 22 com.apple.AppKit 0x00007fff28cf33fa -[NSApplication run] + 586 23 com.apple.AppKit 0x00007fff28cc7224 NSApplicationMain + 816 24 libdyld.dylib 0x00007fff6d1e3851 start + 1

waha commented 4 years ago

For those wanting to compile their own the following diff fixes the crash on Big Sur.

diff --git a/Classes/Session/TSSTPageView.m b/Classes/Session/TSSTPageView.m
index 13b2ed6..86e3b9b 100644
--- a/Classes/Session/TSSTPageView.m
+++ b/Classes/Session/TSSTPageView.m
@@ -304,6 +304,7 @@ - (void)drawRect:(NSRect)aRect

        CALayer* newLayer = [[CALayer alloc]init];

+       NSGraphicsContext *gcontext = NSGraphicsContext.currentContext;
        NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
        NSColor * color = [NSKeyedUnarchiver unarchiveObjectWithData: [defaults valueForKey: TSSTBackgroundColor]];
        self.layer.backgroundColor = [color CGColor];
@@ -429,7 +430,7 @@ - (void)drawRect:(NSRect)aRect
                [newLayer addSublayer:label];
        }

-       [NSGraphicsContext restoreGraphicsState];
+       [gcontext restoreGraphicsState];

        if(acceptingDrag)
        {
nickv2002 commented 4 years ago

Thanks @waha - if you have time please submit a PR that we can merge easily.

waha commented 4 years ago

Thanks for sorting it out for me :)