Allow users to browse, edit, and save images using slideshows and Core Image filters using Quartz.

Posts under Quartz tag

37 Posts

Post

Replies

Boosts

Views

Activity

IKPictureTaker return the abnormal image
IKPictureTaker return the abnormal image. the step: step 1: select image from other, click down. step 2: select the same image from recents. the result: return the abnormal image from a recents selection of photos, but it can only be reproduced under certain images and certain macOS version(eg: OS 10.15.6 / 11.2.3 / 11.6). The certain picture are attached.
2
0
857
Apr ’23
How to identify users connected to Macbook via screen share app
I need to know the list of all users connected live to the system. I am able to fetch the users detail using ioreg -d1 -c IORegistryEntry -a and look for IOConsoleUsers . But this doesn't provide information regarding the users connected via native screen share app of Mac. How can we get this detail via command line or using some files ? Thanks in Advance, Abhilash Vaidhya
1
0
908
Mar ’23
Crash On CA::Render::Encoder::grow(unsigned long) (in QuartzCore) In iOS15.4.1、15,5、15,6.1、16~16.1
1 libsystem_kernel.dylib __pthread_kill (in libsystem_kernel.dylib) + 8 2 libsystem_pthread.dylib pthread_kill (in libsystem_pthread.dylib) + 268 3 libsystem_c.dylib abort (in libsystem_c.dylib) + 180 4 QuartzCore CA::Render::Encoder::grow(unsigned long) (in QuartzCore) + 240 5 QuartzCore CA::Render::Vector::encode(CA::Render::Encoder*) const (in QuartzCore) + 112 6 QuartzCore CA::Render::Array::encode(CA::Render::Encoder*) const (in QuartzCore) + 172 7 QuartzCore CA::Render::KeyframeAnimation::encode(CA::Render::Encoder*) const (in QuartzCore) + 44 8 QuartzCore CA::Context::commit_animation(CA::Layer*, CA::Render::Animation*, void*) (in QuartzCore) + 236 9 QuartzCore CA::Layer::commit_animations(CA::Transaction*, double ()(CA::Layer, double, void*), void ()(CA::Layer, CA::Render::Animation*, void*), void ()(CA::Layer, __CFString const*, void*), CA::Render::TimingList* ()(CA::Layer, void*), void*) (in QuartzCore) + 960 10 QuartzCore invocation function for block in CA::Context::commit_transaction(CA::Transaction*, double, double*) (in QuartzCore) + 220 11 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 368 12 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 13 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 14 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 15 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 16 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 17 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 18 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 19 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 20 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 21 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 22 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 23 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 24 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 25 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 26 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 27 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 28 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 29 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 30 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 31 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 32 QuartzCore CA::Context::commit_transaction(CA::Transaction*, double, double*) (in QuartzCore) + 6268 33 QuartzCore CA::Transaction::commit() (in QuartzCore) + 652 34 QuartzCore CA::Transaction::flush_as_runloop_observer(bool) (in QuartzCore) + 88 35 CoreFoundation CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION (in CoreFoundation) + 36 36 CoreFoundation __CFRunLoopDoObservers (in CoreFoundation) + 532 37 CoreFoundation __CFRunLoopRun (in CoreFoundation) + 1048 38 CoreFoundation CFRunLoopRunSpecific (in CoreFoundation) + 612 39 GraphicsServices GSEventRunModal (in GraphicsServices) + 164 40 UIKitCore -[UIApplication _run] (in UIKitCore) + 888 41 UIKitCore UIApplicationMain (in UIKitCore) + 340
0
0
1.3k
Oct ’22
CAEmitterLayer CAEmitterCell animation bug
CAEmitterLayer emits multiple CAEmitterCells with specified trajectories. When the trajectory CAEmitterCells fly to the end of time, it will become a particle graph displayed by CAEmitterCells, and then the particle graph will be scattered 360 °. However, only one trajectory particle can be animated completely, but more than two particles will appear. The trajectory particle graph will turn white Adding a boomEmitterCell will cause the contents of CAEmitterCell in getDogLeftDownEmitterWithImageName and getRedLeftEmitterWithImageName to not display the picture and white blocks CAEmitterLayer *emitterLayer = [[CAEmitterLayer alloc] init]; emitterLayer.emitterPosition = CGPointMake(self.view.layer.bounds.size.width -100, self.view.layer.bounds.size.height - 100); emitterLayer.emitterSize = CGSizeMake(50, 100.f); emitterLayer.emitterShape = kCAEmitterLayerLine; emitterLayer.emitterMode = kCAEmitterLayerOutline; emitterLayer.renderMode = kCAEmitterLayerOldestLast; CAEmitterCell *dogleftEmitterCell = [self getRedLeftEmitterWithImageName:[imageArray objectAtIndex:0]]; CAEmitterCell *redLeftEmitterCell = [self getRedLeftEmitterWithImageName:[imageArray objectAtIndex:0]]; emitterLayer.emitterCells = @[dogleftEmitterCell,redLeftEmitterCell]; [self.view.layer addSublayer:emitterLayer]; //狗头左下 - (CAEmitterCell *)getDogLeftDownEmitterWithImageName:(NSString *)imageName { CAEmitterCell *emitterCell = [[CAEmitterCell alloc] init]; emitterCell.name = @"左下狗头"; emitterCell.contents = (__bridge id _Nullable)[UIImage imageNamed:@"emoji_6"].CGImage; //产生频率 emitterCell.birthRate = 1; //存活时长 emitterCell.lifetime = 0.6; //速度 emitterCell.velocity = 100; emitterCell.xAcceleration = -1000.f; // 模拟重力影响 emitterCell.scale = 0.2; emitterCell.scaleSpeed = 0.25; emitterCell.emissionLongitude = M_PI_2; // emitterCell.emissionRange = M_PI_4; emitterCell.emitterCells = @[[self boomEmitterCell]]; return emitterCell; } //红包左上 - (CAEmitterCell *)getRedLeftEmitterWithImageName:(NSString *)imageName { CAEmitterCell *emitterCell = [[CAEmitterCell alloc] init]; emitterCell.name = @"红包"; emitterCell.contents = (__bridge id _Nullable)[UIImage imageNamed:@"emoji_7"].CGImage; //产生频率 emitterCell.birthRate = 10; //存活时长 emitterCell.lifetime = 0.6; // emitterCell.beginTime = self.beginTime; //速度 emitterCell.velocity = 100; emitterCell.yAcceleration = -1000.f; // 模拟重力影响 emitterCell.scale = 0.2; // emitterCell.scaleRange = 0.06; emitterCell.scaleSpeed = 0.25; emitterCell.emissionLongitude = M_PI; // CAEmitterCell *emitterCell = [self boomEmitterCell]; emitterCell.emitterCells = @[[self boomEmitterCell]]; return emitterCell; } - (CAEmitterCell *)boomEmitterCell { // 爆炸 CAEmitterCell * explodeCell = [CAEmitterCell emitterCell]; explodeCell.name = @"explodeCell"; explodeCell.birthRate = 2.f; explodeCell.lifetime = 0.6f; // explodeCell.velocity = 0.f; // explodeCell.scale = 1.0; // explodeCell.redSpeed = -1.5; //爆炸的时候变化颜色 // explodeCell.blueRange = 1.5; //爆炸的时候变化颜色 // explodeCell.greenRange = 1.f; //爆炸的时候变化颜色 // explodeCell.birthRate = 1.0; // explodeCell.velocity = 0; // explodeCell.scale = 2.5; // explodeCell.redSpeed =-1.5; // explodeCell.blueSpeed =+1.5; // explodeCell.greenSpeed =+1.0; // explodeCell.lifetime = 0.35; explodeCell.contents = (__bridge id _Nullable)[[UIImage imageNamed:@"allStart"] CGImage]; // 火花 // CAEmitterCell * sparkCell = [CAEmitterCell emitterCell]; // sparkCell.name = @"sparkCell"; // // sparkCell.birthRate = 3.f; // sparkCell.lifetime = 3.f; // sparkCell.velocity = 125.f; //// sparkCell.yAcceleration = 75.f; // 模拟重力影响 // sparkCell.emissionRange = M_PI * 2; // 360度 // // sparkCell.scale = 1.2f; // sparkCell.contents = (id)[[UIImage imageNamed:@"star_white_stroke"] CGImage]; // sparkCell.redSpeed = 0.4; // sparkCell.greenSpeed = -0.1; // sparkCell.blueSpeed = -0.1; // sparkCell.alphaSpeed = -0.25; // explodeCell.emitterCells = @[sparkCell]; return explodeCell; }
0
0
1.1k
Oct ’22
UIKitCore-[UIViewController _nonModalAncestorViewControllerStopAtIsPresentationContext:]
Hi we are getting this crash from Crashlytics, We are unable to reproduce it. Sharing the logs we have. Please help in this. Crash Item : UIKitCore-[UIViewController _nonModalAncestorViewControllerStopAtIsPresentationContext:] Issue Details : Crashed: com.apple.main-thread 0 libobjc.A.dylib 0x1f58 objc_msgSend + 56 1 UIKitCore 0x519e78 -[UIViewController _nonModalAncestorViewControllerStopAtIsPresentationContext:] + 56 2 UIKitCore 0x21a818 -[UIViewController _rootAncestorViewControllerInWindow:] + 44 3 UIKitCore 0x27d4f8 -[UIViewController _window] + 152 4 UIKitCore 0x1ae824 -[UIViewController loadViewIfRequired] + 240 5 UIKitCore 0x181bac -[UIViewController view] + 32 6 UIKitCore 0x323178 -[UIInputWindowController changeToInputViewSet:] + 1088 7 UIKitCore 0xd434ac __43-[UIInputWindowController setInputViewSet:]_block_invoke.1288 + 40 8 UIKitCore 0xd401d4 __77-[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:]_block_invoke.1045 + 1600 9 UIKitCore 0x12aa4dc UIVIEW_IS_EXECUTING_ANIMATION_COMPLETION_BLOCK + 36 10 UIKitCore 0x2c2fa4 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 728 11 UIKitCore 0x18ed04 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 248 12 UIKitCore 0x1a3504 -[UIViewAnimationState animationDidStop:finished:] + 244 13 QuartzCore 0xcbe50 CA::Layer::run_animation_callbacks(void*) + 280 14 libdispatch.dylib 0x3a30 _dispatch_client_callout + 20 15 libdispatch.dylib 0x11f48 _dispatch_main_queue_drain + 928 16 libdispatch.dylib 0x11b98 _dispatch_main_queue_callback_4CF + 44 17 CoreFoundation 0x51800 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 16 18 CoreFoundation 0xb704 __CFRunLoopRun + 2532 19 CoreFoundation 0x1ebc8 CFRunLoopRunSpecific + 600 20 GraphicsServices 0x1374 GSEventRunModal + 164 21 UIKitCore 0x514b58 -[UIApplication _run] + 1100 22 UIKitCore 0x296090 UIApplicationMain + 364 23 App 0xbad894 main + 39 (AppDelegate.swift:39) 24 ??? 0x104d65da4 (Missing)
1
0
1.5k
Sep ’22
How to create and store the pdf file
I'm using CGContext.init(withUrl) to create a pdf context and doing some rendering inside that context. I was able to save the pdf in the location which will be available in the url. But in my case i will not have a location while creating the CGContext. So in my case i need a create a CGPDFContext without the location. I tried using the CGDataConsumer, but that also not working. My Requirements 1. Have to create PDF file without the save location. 2. In certain time interval i have to save that pdf to the particular location
3
0
3.6k
Aug ’22
display capture issue
I have an app which captures a display (CGDisplayCapture or CGDisplayCaptureWithOptions), grabs its drawing context, and then draw image on it: //1. capture auto cpErr = CGDisplayCaptureWithOptions( mDid, kCGCaptureNoOptions );   if ( cpErr != kCGErrorSuccess )   {     LOGEX( "😂 Failed to capture Display, ID:%d", mDId );     return;   } // Grab context context = CGDisplayGetDrawingContext( mDId ); //Draw image CGContextDrawImage( context, rect, image ); CGContextFlush( context ); The video is pretty good, but two issues: When captured, according to the document, it only capture the event on that display, actually, when the app running, all system key event (i.g. Shift+Cmd+R) and swipe won't work. CGContextDrawImage is taking pretty high CPU usage, in my Mac mini 2018, it is taking over 20% Anyone got the solution to the above issues? -Thanks :)
0
0
948
Aug ’22
App Getting Crash at UIKitCore -[UITableView _configureCellPrefetchingHandlers]
Please refer below crashlytics Stack trace we had many crashes seeing in firebase crashlytics for latest build. Crashed: com.apple.main-thread 0 libsystem_kernel.dylib 0x2d328 __abort_with_payload + 8 1 libsystem_kernel.dylib 0x2fc34 abort_with_payload_wrapper_internal + 104 2 libsystem_kernel.dylib 0x2fbcc abort_with_payload_wrapper_internal + 30 3 libobjc.A.dylib 0x2d0d4 _objc_fatalv(unsigned long long, unsigned long long, char const*, char*) + 116 4 libobjc.A.dylib 0x2d060 _objc_fatalv(unsigned long long, unsigned long long, char const*, char*) + 30 5 libobjc.A.dylib 0x5a60 weak_register_no_lock + 392 6 libobjc.A.dylib 0xb3e0 objc_initWeak + 400 7 UIKitCore 0x4f93f0 -[UITableView _configureCellPrefetchingHandlers] + 288 8 UIKitCore 0x17b500 -[UITableView layoutSubviews] + 296 9 UIKitCore 0x18b844 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2592 10 QuartzCore 0x401c0 CA::Layer::layout_if_needed(CA::Transaction*) + 532 11 QuartzCore 0x325fc CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 136 12 QuartzCore 0x46f70 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 452 13 QuartzCore 0x4fe78 CA::Transaction::commit() + 704 14 QuartzCore 0x31d7c CA::Transaction::flush_as_runloop_observer(bool) + 88 15 UIKitCore 0x53d9d8 _UIApplicationFlushCATransaction + 72 16 UIKitCore 0x7d8084 _UIUpdateSequenceRun + 84 17 UIKitCore 0xe5dcb0 schedulerStepScheduledMainSection + 144 18 UIKitCore 0xe5d478 runloopSourceCallback + 92 19 CoreFoundation 0xbbf04 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 20 CoreFoundation 0xccc90 __CFRunLoopDoSource0 + 208 21 CoreFoundation 0x6184 __CFRunLoopDoSources0 + 268 22 CoreFoundation 0xbb4c __CFRunLoopRun + 828 23 CoreFoundation 0x1f6b8 CFRunLoopRunSpecific + 600 24 GraphicsServices 0x1374 GSEventRunModal + 164 25 UIKitCore 0x513e88 -[UIApplication _run] + 1100 26 UIKitCore 0x2955ec UIApplicationMain + 364 27 libswiftUIKit.dylib 0x30ecc UIApplicationMain(_:_:_:_:) + 104 28 AbhiBus 0x81fc main + 12 (main.swift:12) 29 ??? 0x10211dce4 (Missing)
1
0
1.2k
May ’22
API for rotating display
Greetings, Recently I want to make a application that is capable of rotating my external display. I found these related APIs CGBeginDisplayConfiguration, CGDisplayRotation. The first one let me change height and width of display, but not the rotation angle, and the second one only shows the current rotation angle. I wonder is it possible for us to change the rotation of display someway through API? Thank you, Kuroame
0
0
855
May ’22
How to use IOSurface instead of NSOpenGLPixelBuffer on Mac? How to use GL_EXT_framebuffer_object instead?
I used to have a project that used Quartz Composer and OpenGL, but Xcode 13 has deprecated these two components, which caused me to fail to get off-screen images during video production. The previous code to create the OpenGLContext is as follows: (id) initOffScreenOpenGLPixelsWide:(unsigned)width pixelsHigh:(unsigned)height { //Check parameters - Rendering at sizes smaller than 16x16 will likely produce garbage if((width < 16) || (height < 16)) { [self release]; return nil; } self = [super init]; if(self != nil) {         NSOpenGLPixelFormatAttribute pixattributes[] = {             NSOpenGLPFADoubleBuffer,             NSOpenGLPFANoRecovery,             NSOpenGLPFAAccelerated,             NSOpenGLPFADepthSize, 24,             (NSOpenGLPixelFormatAttribute) 0         };         _pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:pixattributes]; //Create the OpenGL context to render with (with color and depth buffers) _openGLContext = [[NSOpenGLContext alloc] initWithFormat:_pixelFormat shareContext:nil]; if(_openGLContext == nil) { DDLogInfo(@"Cannot create OpenGL context"); [self release]; return nil; }                  //Create the OpenGL pixel buffer to render into         NSOpenGLPixelBuffer* glPixelBuffer = [[NSOpenGLPixelBuffer alloc] initWithTextureTarget:GL_TEXTURE_RECTANGLE_EXT    textureInternalFormat:GL_RGBA textureMaxMipMapLevel:0 pixelsWide:width pixelsHigh:height];         if(glPixelBuffer == nil) {             DDLogInfo(@"Cannot create OpenGL pixel buffer");             [self release];             return nil;         }         [_openGLContext setPixelBuffer:glPixelBuffer cubeMapFace:0 mipMapLevel:0 currentVirtualScreen:[_openGLContext currentVirtualScreen]];                  //Destroy the OpenGL pixel buffer         [glPixelBuffer release];          NSMutableDictionary* attributes = [NSMutableDictionary dictionary];         [attributes setObject:[NSNumber numberWithUnsignedInt:k32BGRAPixelFormat] forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey]; [attributes setObject:[NSNumber numberWithUnsignedInt:width] forKey:(NSString*)kCVPixelBufferWidthKey]; [attributes setObject:[NSNumber numberWithUnsignedInt:height] forKey:(NSString*)kCVPixelBufferHeightKey]; //Create buffer pool to hold our frames OSErr theError = CVPixelBufferPoolCreate(kCFAllocatorDefault, NULL, (CFDictionaryRef)attributes, &_bufferPool); if(theError != kCVReturnSuccess)  { DDLogInfo(@"CVPixelBufferPoolCreate() failed with error %i", theError); [self release]; return nil; } }     /*      *A context is current on a per-thread basis. Multiple threads must serialize calls into the same context object.      */     [self.openGLContext makeCurrentContext]; return self; } By creating an NSOpenGLPixelBuffer object, and then setting the pixelbuffer of NSOpenGLContext, but in Xcode13, NSOpenGLPixelBuffer cannot be created successfully. Looking at the help documentation, it is recommended to use GL_EXT_framebuffer_object instead. So I tried the following code::         //RGBA8 RenderBuffer, 24 bit depth RenderBuffer, 256x256         glGenFramebuffersEXT(1, &fb);         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);         //Create and attach a color buffer                  glGenRenderbuffersEXT(1, &color_rb);         //We must bind color_rb before we call glRenderbufferStorageEXT         glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, color_rb);         //The storage format is RGBA8         glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA, width, height);         //Attach color buffer to FBO         glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, color_rb);         //-------------------------                  glGenRenderbuffersEXT(1, &depth_rb);         glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth_rb);         glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, width, height);         //-------------------------         //Attach depth buffer to FBO         glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb);         //-------------------------         //Does the GPU support current FBO configuration?         GLenum status;         status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);         switch(status)         {             case GL_FRAMEBUFFER_COMPLETE_EXT:                 DDLogInfo(@"gl no problem");                 break;             default:                 DDLogInfo(@"error");                 break;         }                  //-------------------------         //and now you can render to the FBO (also called RenderBuffer)         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); When running the program we can get the 'gl no problem' log. However, when reading off-screen image data, although glGetError does not return an error code, I can only read a black image. In previous versions, a QCRenderer rendered image could be successfully obtained. Reading off-screen images is implemented as follows: (CVPixelBufferRef) readPixelBuffer {     // Create pixel buffer from pixel buffer pool     CVPixelBufferRef bufferRef;     OSErr theError = CVPixelBufferPoolCreatePixelBuffer(kCFAllocatorDefault, _bufferPool, &bufferRef);     if(theError) {         DDLogInfo(@"CVPixelBufferPoolCreatePixelBuffer() failed with error %i", theError);         return nil;     }     theError = CVPixelBufferLockBaseAddress(bufferRef, 0); if(theError) { DDLogInfo(@"CVPixelBufferLockBaseAddress() failed with error %i", theError); return nil; } void* bufferPtr = CVPixelBufferGetBaseAddress(bufferRef);     size_t width = CVPixelBufferGetWidth(bufferRef);     size_t height = CVPixelBufferGetHeight(bufferRef); size_t bufferRowBytes = CVPixelBufferGetBytesPerRow(bufferRef);     CGLContextObj cgl_ctx = [_openGLContext CGLContextObj]; CGLLockContext(cgl_ctx);     //Read pixels back from the OpenGL pixel buffer in ARGB 32 bits format - For extra safety, we save / restore the OpenGL states we change     GLint save; glGetIntegerv(GL_PACK_ROW_LENGTH, &save); glPixelStorei(GL_PACK_ROW_LENGTH, (int)bufferRowBytes / 4); glReadPixels(0, 0, (GLsizei)width, (GLsizei)height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, bufferPtr);     flipImage(bufferPtr, width, height, bufferRowBytes);     glPixelStorei(GL_PACK_ROW_LENGTH, save); CGLUnlockContext(cgl_ctx);     GLenum code = glGetError(); if(code) return nil; CVPixelBufferUnlockBaseAddress(bufferRef, 0);     return bufferRef; } Ask an expert how to solve this problem.
0
0
1.3k
Apr ’22
occasional crashes in CGContext.drawPDFPage
Hi,in our app we render PDF pages with a CATiledLayer to screen. We have occasional crashes mostly on iPads. Every time it crashes there are two or three concurrent threads rendering the page. I'm not able to reproduce it.Any idea how to fix this?Code looks like this: override func draw(_ layer: CALayer, in ctx: CGContext) { guard let page = self.page else { return } ctx.setFillColor(red: 1.0,green: 1.0,blue: 1.0,alpha: 1.0) ctx.fill(ctx.boundingBoxOfClipPath) let layerSize = layer.bounds.size // Flip the context so that the PDF page is rendered right side up. ctx.translateBy(x: 0.0, y: layerSize.height) ctx.scaleBy(x: 1.0, y: -1.0) let pageMediaBox = page.getBoxRect(.mediaBox) let fillWithPDFPageVerticalProportion = layerSize.height / pageMediaBox.height let fillWithPDFPageHorizontalProportion = layerSize.width / pageMediaBox.width let fillWithPDFPageProportion = min(fillWithPDFPageVerticalProportion, fillWithPDFPageHorizontalProportion) ctx.translateBy( x: -(pageMediaBox.width * fillWithPDFPageProportion - layerSize.width) / 2, y: -(pageMediaBox.height * fillWithPDFPageProportion - layerSize.height) / 2 ) ctx.scaleBy(x: fillWithPDFPageProportion, y: fillWithPDFPageProportion) ctx.drawPDFPage(page) }This is a stack trace from the crashing thread:#8. Crashed: com.apple.root.default-qos0 libobjc.A.dylib 0x185a8c1a0 objc_retain + 161 ImageIO 0x1888dd5cc IIOImageRead::IIOImageRead(CGDataProvider*, bool) + 882 ImageIO 0x1888df93c CGImageReadCreateWithProvider + 1963 ImageIO 0x18874ac6c IIOImageSource::IIOImageSource(CGDataProvider*, IIODictionary*) + 964 ImageIO 0x18874ec50 CGImageSourceCreateWithDataProvider + 1725 CoreGraphics 0x18803a464 CGImageCreateWithJPEGDataProvider3 + 846 CoreGraphics 0x187fb7264 create_image_for_image + 1887 CoreGraphics 0x187fb713c CGPDFImageCreateImage + 1848 CoreGraphics 0x1880256f8 CGPDFDrawingContextDrawImage + 409 CoreGraphics 0x1880de03c op_Do + 10410 CoreGraphics 0x1882e6684 pdf_scanner_handle_xname + 14411 CoreGraphics 0x1882e5f0c CGPDFScannerScan + 36812 CoreGraphics 0x1882f0170 CGPDFDrawingContextDrawPage + 51613 CoreGraphics 0x1880c0a04 pdf_page_draw_in_context + 13214 CoreGraphics 0x187fa763c CGContextDrawPDFPageWithDrawingCallbacks + 7615 CoreGraphics 0x187fa7310 CGContextDrawPDFPage + 3216 myApp 0x1009e8cf0 specialized PDFTiledView.draw(CALayer, in : CGContext) -&gt; () (PDFTiledView.swift:59)17 myApp 0x1009e88ec @objc PDFTiledView.draw(CALayer, in : CGContext) -&gt; () (PDFTiledView.swift)18 QuartzCore 0x18a86b51c -[CALayer drawInContext:] + 29619 QuartzCore 0x18a79c780 tiled_layer_render(_CAImageProvider*, unsigned int, unsigned int, unsigned int, unsigned int, void*) + 153220 QuartzCore 0x18a836448 CAImageProviderThread(unsigned int*, bool) + 81221 libdispatch.dylib 0x1861a6a14 _dispatch_client_callout + 1622 libdispatch.dylib 0x1861adbc8 _dispatch_queue_override_invoke$VARIANT$mp + 71623 libdispatch.dylib 0x1861b3cf4 _dispatch_root_queue_drain + 60024 libdispatch.dylib 0x1861b3a38 _dispatch_worker_thread3 + 12025 libsystem_pthread.dylib 0x18644f06c _pthread_wqthread + 126826 libsystem_pthread.dylib 0x18644eb6c start_wqthread + 4There are two threads with this stack trace:#9. com.apple.root.default-qos0 libsystem_kernel.dylib 0x18633c138 __psynch_mutexwait + 81 libsystem_pthread.dylib 0x186453660 _pthread_mutex_lock_wait + 962 libsystem_pthread.dylib 0x1864535a4 _pthread_mutex_lock_slow$VARIANT$mp + 2643 CoreGraphics 0x187fb70ac CGPDFImageCreateImage + 404 CoreGraphics 0x1880256f8 CGPDFDrawingContextDrawImage + 405 CoreGraphics 0x1880de03c op_Do + 1046 CoreGraphics 0x1882e6684 pdf_scanner_handle_xname + 1447 CoreGraphics 0x1882e5f0c CGPDFScannerScan + 3688 CoreGraphics 0x1882f0170 CGPDFDrawingContextDrawPage + 5169 CoreGraphics 0x1880c0a04 pdf_page_draw_in_context + 13210 CoreGraphics 0x187fa763c CGContextDrawPDFPageWithDrawingCallbacks + 7611 CoreGraphics 0x187fa7310 CGContextDrawPDFPage + 3212 myApp 0x1009e8cf0 specialized PDFTiledView.draw(CALayer, in : CGContext) -&gt; () (PDFTiledView.swift:59)13 myApp 0x1009e88ec @objc PDFTiledView.draw(CALayer, in : CGContext) -&gt; () (PDFTiledView.swift)14 QuartzCore 0x18a86b51c -[CALayer drawInContext:] + 29615 QuartzCore 0x18a79c780 tiled_layer_render(_CAImageProvider*, unsigned int, unsigned int, unsigned int, unsigned int, void*) + 153216 QuartzCore 0x18a836448 CAImageProviderThread(unsigned int*, bool) + 81217 libdispatch.dylib 0x1861a6a14 _dispatch_client_callout + 1618 libdispatch.dylib 0x1861adbc8 _dispatch_queue_override_invoke$VARIANT$mp + 71619 libdispatch.dylib 0x1861b3cf4 _dispatch_root_queue_drain + 60020 libdispatch.dylib 0x1861b3a38 _dispatch_worker_thread3 + 12021 libsystem_pthread.dylib 0x18644f06c _pthread_wqthread + 126822 libsystem_pthread.dylib 0x18644eb6c start_wqthread + 4Thanks,Snert
2
0
2.9k
Dec ’21
Touch area does not matched with Image after SubImage is sized up
If I enlarge up the Image 8x with pinch out gesture, there is a phenomenon that displaying area of the subimage and the touchable area of the sub image is not matched I think it looks like the touchable area has been moved from the image area to the top left by 20dp. Please guide me on how to exactly match the displayed area and the touched area of the subimage on the ImageView I set the autoresizesSubViews property of ImageView to true, and Subimages were scaled with CATransform3DMakeScale when pinched out.
0
0
547
Nov ’21
drawing into an existing CGImage
Ok, maybe I'm hung up on Mac OS X design patterns, just tell me if that's the case.the problem:I need to draw a line on an existing CGImage.There's no LockFocus methods for CGImage, There's no obvious documented way to get the already created Context of a Bitmap in the CGImage. There's no obvious or explicit code explaining the procedure.I have the reference to the image, I have the two points that make up the line, I know all of the code to draw that line... I just cannot make the context associated to that image, the current context. What gives? what is the design pattern? Please tell me where I can read about this.
3
0
2.8k
Nov ’21
WKWebView play video crash on some Model
When I opened the video in HTML, it crashed when I started playing it。 Here is my app crash report: 0 CoreFoundation __HALT + 2 arrow_right 1 QuartzCore CA::Layer::setter(unsigned int, _CAValueType, void const*) + 252 2 QuartzCore[CALayer setBackgroundColor:] + 56 3 QuartzCore[CAStateSetValue apply:] + 620 4 QuartzCore[CAStateController setState:ofLayer:transitionSpeed:] + 1364 5 AVKit[AVMicaPackage transitionToStateWithName:onLayer:] + 144 6 AVKit[AVMicaPackage transitionToStateWithName:] + 92 7 AVKit[AVMicaPackage _setState:] + 108 8 AVKit[AVMicaPackage setState:color:] + 116 9 AVKit[AVPlaybackControlsRoutePickerView updateButtonAppearance] + 204 10 AVKit[AVRoutePickerView layoutSubviews] + 632 11 UIKitCore[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2500 12 QuartzCore[CALayer layoutSublayers] + 296 13 QuartzCore CA::Layer::layout_if_needed(CA::Transaction*) + 524 14 QuartzCore CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 144 15 QuartzCore CA::Context::commit_transaction(CA::Transaction*, double, double*) + 416 16 QuartzCore CA::Transaction::commit() + 732 17 QuartzCore CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 96 18 CoreFoundation CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 36 19 CoreFoundation __CFRunLoopDoObservers + 576 20 CoreFoundation __CFRunLoopRun + 1056 21 CoreFoundation CFRunLoopRunSpecific + 600 22 GraphicsServices GSEventRunModal + 164 23 UIKitCore[UIApplication _run] + 1072 24 UIKitCore UIApplicationMain + 168 25 AXNews main.m - 第 15 行 main + 15 26 libdyld.dylib start + 4
3
0
1.4k
Oct ’21
UIImage from snapshot view?
On iOS, I'm trying to convert the contents of a view produced by snapshotView(afterScreenUpdates:) into a UIImage. At the point where I'm trying to do this, I no longer have the underlying objects that were rendered into the snapshot - I only have the snapshot view.Although this snapshot view displays correctly on the device screen at all times, I seem to be unable to convert it to an image to save to disk.For example, say I do something like: let ssView = someView.snapshotView(afterScreenUpdates:true)And then later, I want to convert ssView to a UIImage. I have tried all the usual patterns that work with other (non-snapshot) views such as: UIGraphicsBeginImageContext(ssView.frame.size) ssView.drawHierarchy(in: ssView.bounds, afterScreenUpdates: true) let image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext()or let renderer = UIGraphicsImageRenderer(size: ssView.frame.size) let image = renderer.image { context in return ssView.layer.render(in: context.cgContext) }And many other variations... I've also tried to render the hierarchy from superviews of the snapshot view but no matter what I try, it doesn't work. Attempting to capture the snapshot view directly produces a blank image and if the parent view is captured, the portion of the screen where the snapshot view resides is blank.Does anyone have any idea how to make this work?Thanks,David
2
0
3.3k
Aug ’21
IKPictureTaker return the abnormal image
IKPictureTaker return the abnormal image. the step: step 1: select image from other, click down. step 2: select the same image from recents. the result: return the abnormal image from a recents selection of photos, but it can only be reproduced under certain images and certain macOS version(eg: OS 10.15.6 / 11.2.3 / 11.6). The certain picture are attached.
Replies
2
Boosts
0
Views
857
Activity
Apr ’23
How to identify users connected to Macbook via screen share app
I need to know the list of all users connected live to the system. I am able to fetch the users detail using ioreg -d1 -c IORegistryEntry -a and look for IOConsoleUsers . But this doesn't provide information regarding the users connected via native screen share app of Mac. How can we get this detail via command line or using some files ? Thanks in Advance, Abhilash Vaidhya
Replies
1
Boosts
0
Views
908
Activity
Mar ’23
Crash On CA::Render::Encoder::grow(unsigned long) (in QuartzCore) In iOS15.4.1、15,5、15,6.1、16~16.1
1 libsystem_kernel.dylib __pthread_kill (in libsystem_kernel.dylib) + 8 2 libsystem_pthread.dylib pthread_kill (in libsystem_pthread.dylib) + 268 3 libsystem_c.dylib abort (in libsystem_c.dylib) + 180 4 QuartzCore CA::Render::Encoder::grow(unsigned long) (in QuartzCore) + 240 5 QuartzCore CA::Render::Vector::encode(CA::Render::Encoder*) const (in QuartzCore) + 112 6 QuartzCore CA::Render::Array::encode(CA::Render::Encoder*) const (in QuartzCore) + 172 7 QuartzCore CA::Render::KeyframeAnimation::encode(CA::Render::Encoder*) const (in QuartzCore) + 44 8 QuartzCore CA::Context::commit_animation(CA::Layer*, CA::Render::Animation*, void*) (in QuartzCore) + 236 9 QuartzCore CA::Layer::commit_animations(CA::Transaction*, double ()(CA::Layer, double, void*), void ()(CA::Layer, CA::Render::Animation*, void*), void ()(CA::Layer, __CFString const*, void*), CA::Render::TimingList* ()(CA::Layer, void*), void*) (in QuartzCore) + 960 10 QuartzCore invocation function for block in CA::Context::commit_transaction(CA::Transaction*, double, double*) (in QuartzCore) + 220 11 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 368 12 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 13 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 14 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 15 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 16 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 17 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 18 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 19 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 20 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 21 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 22 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 23 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 24 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 25 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 26 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 27 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 28 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 29 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 30 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 31 QuartzCore CA::Layer::commit_if_needed(CA::Transaction*, void (CA::Layer*, unsigned int, unsigned int) block_pointer) (in QuartzCore) + 252 32 QuartzCore CA::Context::commit_transaction(CA::Transaction*, double, double*) (in QuartzCore) + 6268 33 QuartzCore CA::Transaction::commit() (in QuartzCore) + 652 34 QuartzCore CA::Transaction::flush_as_runloop_observer(bool) (in QuartzCore) + 88 35 CoreFoundation CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION (in CoreFoundation) + 36 36 CoreFoundation __CFRunLoopDoObservers (in CoreFoundation) + 532 37 CoreFoundation __CFRunLoopRun (in CoreFoundation) + 1048 38 CoreFoundation CFRunLoopRunSpecific (in CoreFoundation) + 612 39 GraphicsServices GSEventRunModal (in GraphicsServices) + 164 40 UIKitCore -[UIApplication _run] (in UIKitCore) + 888 41 UIKitCore UIApplicationMain (in UIKitCore) + 340
Replies
0
Boosts
0
Views
1.3k
Activity
Oct ’22
CAEmitterLayer CAEmitterCell animation bug
CAEmitterLayer emits multiple CAEmitterCells with specified trajectories. When the trajectory CAEmitterCells fly to the end of time, it will become a particle graph displayed by CAEmitterCells, and then the particle graph will be scattered 360 °. However, only one trajectory particle can be animated completely, but more than two particles will appear. The trajectory particle graph will turn white Adding a boomEmitterCell will cause the contents of CAEmitterCell in getDogLeftDownEmitterWithImageName and getRedLeftEmitterWithImageName to not display the picture and white blocks CAEmitterLayer *emitterLayer = [[CAEmitterLayer alloc] init]; emitterLayer.emitterPosition = CGPointMake(self.view.layer.bounds.size.width -100, self.view.layer.bounds.size.height - 100); emitterLayer.emitterSize = CGSizeMake(50, 100.f); emitterLayer.emitterShape = kCAEmitterLayerLine; emitterLayer.emitterMode = kCAEmitterLayerOutline; emitterLayer.renderMode = kCAEmitterLayerOldestLast; CAEmitterCell *dogleftEmitterCell = [self getRedLeftEmitterWithImageName:[imageArray objectAtIndex:0]]; CAEmitterCell *redLeftEmitterCell = [self getRedLeftEmitterWithImageName:[imageArray objectAtIndex:0]]; emitterLayer.emitterCells = @[dogleftEmitterCell,redLeftEmitterCell]; [self.view.layer addSublayer:emitterLayer]; //狗头左下 - (CAEmitterCell *)getDogLeftDownEmitterWithImageName:(NSString *)imageName { CAEmitterCell *emitterCell = [[CAEmitterCell alloc] init]; emitterCell.name = @"左下狗头"; emitterCell.contents = (__bridge id _Nullable)[UIImage imageNamed:@"emoji_6"].CGImage; //产生频率 emitterCell.birthRate = 1; //存活时长 emitterCell.lifetime = 0.6; //速度 emitterCell.velocity = 100; emitterCell.xAcceleration = -1000.f; // 模拟重力影响 emitterCell.scale = 0.2; emitterCell.scaleSpeed = 0.25; emitterCell.emissionLongitude = M_PI_2; // emitterCell.emissionRange = M_PI_4; emitterCell.emitterCells = @[[self boomEmitterCell]]; return emitterCell; } //红包左上 - (CAEmitterCell *)getRedLeftEmitterWithImageName:(NSString *)imageName { CAEmitterCell *emitterCell = [[CAEmitterCell alloc] init]; emitterCell.name = @"红包"; emitterCell.contents = (__bridge id _Nullable)[UIImage imageNamed:@"emoji_7"].CGImage; //产生频率 emitterCell.birthRate = 10; //存活时长 emitterCell.lifetime = 0.6; // emitterCell.beginTime = self.beginTime; //速度 emitterCell.velocity = 100; emitterCell.yAcceleration = -1000.f; // 模拟重力影响 emitterCell.scale = 0.2; // emitterCell.scaleRange = 0.06; emitterCell.scaleSpeed = 0.25; emitterCell.emissionLongitude = M_PI; // CAEmitterCell *emitterCell = [self boomEmitterCell]; emitterCell.emitterCells = @[[self boomEmitterCell]]; return emitterCell; } - (CAEmitterCell *)boomEmitterCell { // 爆炸 CAEmitterCell * explodeCell = [CAEmitterCell emitterCell]; explodeCell.name = @"explodeCell"; explodeCell.birthRate = 2.f; explodeCell.lifetime = 0.6f; // explodeCell.velocity = 0.f; // explodeCell.scale = 1.0; // explodeCell.redSpeed = -1.5; //爆炸的时候变化颜色 // explodeCell.blueRange = 1.5; //爆炸的时候变化颜色 // explodeCell.greenRange = 1.f; //爆炸的时候变化颜色 // explodeCell.birthRate = 1.0; // explodeCell.velocity = 0; // explodeCell.scale = 2.5; // explodeCell.redSpeed =-1.5; // explodeCell.blueSpeed =+1.5; // explodeCell.greenSpeed =+1.0; // explodeCell.lifetime = 0.35; explodeCell.contents = (__bridge id _Nullable)[[UIImage imageNamed:@"allStart"] CGImage]; // 火花 // CAEmitterCell * sparkCell = [CAEmitterCell emitterCell]; // sparkCell.name = @"sparkCell"; // // sparkCell.birthRate = 3.f; // sparkCell.lifetime = 3.f; // sparkCell.velocity = 125.f; //// sparkCell.yAcceleration = 75.f; // 模拟重力影响 // sparkCell.emissionRange = M_PI * 2; // 360度 // // sparkCell.scale = 1.2f; // sparkCell.contents = (id)[[UIImage imageNamed:@"star_white_stroke"] CGImage]; // sparkCell.redSpeed = 0.4; // sparkCell.greenSpeed = -0.1; // sparkCell.blueSpeed = -0.1; // sparkCell.alphaSpeed = -0.25; // explodeCell.emitterCells = @[sparkCell]; return explodeCell; }
Replies
0
Boosts
0
Views
1.1k
Activity
Oct ’22
UIKitCore-[UIViewController _nonModalAncestorViewControllerStopAtIsPresentationContext:]
Hi we are getting this crash from Crashlytics, We are unable to reproduce it. Sharing the logs we have. Please help in this. Crash Item : UIKitCore-[UIViewController _nonModalAncestorViewControllerStopAtIsPresentationContext:] Issue Details : Crashed: com.apple.main-thread 0 libobjc.A.dylib 0x1f58 objc_msgSend + 56 1 UIKitCore 0x519e78 -[UIViewController _nonModalAncestorViewControllerStopAtIsPresentationContext:] + 56 2 UIKitCore 0x21a818 -[UIViewController _rootAncestorViewControllerInWindow:] + 44 3 UIKitCore 0x27d4f8 -[UIViewController _window] + 152 4 UIKitCore 0x1ae824 -[UIViewController loadViewIfRequired] + 240 5 UIKitCore 0x181bac -[UIViewController view] + 32 6 UIKitCore 0x323178 -[UIInputWindowController changeToInputViewSet:] + 1088 7 UIKitCore 0xd434ac __43-[UIInputWindowController setInputViewSet:]_block_invoke.1288 + 40 8 UIKitCore 0xd401d4 __77-[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:]_block_invoke.1045 + 1600 9 UIKitCore 0x12aa4dc UIVIEW_IS_EXECUTING_ANIMATION_COMPLETION_BLOCK + 36 10 UIKitCore 0x2c2fa4 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 728 11 UIKitCore 0x18ed04 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 248 12 UIKitCore 0x1a3504 -[UIViewAnimationState animationDidStop:finished:] + 244 13 QuartzCore 0xcbe50 CA::Layer::run_animation_callbacks(void*) + 280 14 libdispatch.dylib 0x3a30 _dispatch_client_callout + 20 15 libdispatch.dylib 0x11f48 _dispatch_main_queue_drain + 928 16 libdispatch.dylib 0x11b98 _dispatch_main_queue_callback_4CF + 44 17 CoreFoundation 0x51800 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 16 18 CoreFoundation 0xb704 __CFRunLoopRun + 2532 19 CoreFoundation 0x1ebc8 CFRunLoopRunSpecific + 600 20 GraphicsServices 0x1374 GSEventRunModal + 164 21 UIKitCore 0x514b58 -[UIApplication _run] + 1100 22 UIKitCore 0x296090 UIApplicationMain + 364 23 App 0xbad894 main + 39 (AppDelegate.swift:39) 24 ??? 0x104d65da4 (Missing)
Replies
1
Boosts
0
Views
1.5k
Activity
Sep ’22
How to create and store the pdf file
I'm using CGContext.init(withUrl) to create a pdf context and doing some rendering inside that context. I was able to save the pdf in the location which will be available in the url. But in my case i will not have a location while creating the CGContext. So in my case i need a create a CGPDFContext without the location. I tried using the CGDataConsumer, but that also not working. My Requirements 1. Have to create PDF file without the save location. 2. In certain time interval i have to save that pdf to the particular location
Replies
3
Boosts
0
Views
3.6k
Activity
Aug ’22
display capture issue
I have an app which captures a display (CGDisplayCapture or CGDisplayCaptureWithOptions), grabs its drawing context, and then draw image on it: //1. capture auto cpErr = CGDisplayCaptureWithOptions( mDid, kCGCaptureNoOptions );   if ( cpErr != kCGErrorSuccess )   {     LOGEX( "😂 Failed to capture Display, ID:%d", mDId );     return;   } // Grab context context = CGDisplayGetDrawingContext( mDId ); //Draw image CGContextDrawImage( context, rect, image ); CGContextFlush( context ); The video is pretty good, but two issues: When captured, according to the document, it only capture the event on that display, actually, when the app running, all system key event (i.g. Shift+Cmd+R) and swipe won't work. CGContextDrawImage is taking pretty high CPU usage, in my Mac mini 2018, it is taking over 20% Anyone got the solution to the above issues? -Thanks :)
Replies
0
Boosts
0
Views
948
Activity
Aug ’22
App Getting Crash at UIKitCore -[UITableView _configureCellPrefetchingHandlers]
Please refer below crashlytics Stack trace we had many crashes seeing in firebase crashlytics for latest build. Crashed: com.apple.main-thread 0 libsystem_kernel.dylib 0x2d328 __abort_with_payload + 8 1 libsystem_kernel.dylib 0x2fc34 abort_with_payload_wrapper_internal + 104 2 libsystem_kernel.dylib 0x2fbcc abort_with_payload_wrapper_internal + 30 3 libobjc.A.dylib 0x2d0d4 _objc_fatalv(unsigned long long, unsigned long long, char const*, char*) + 116 4 libobjc.A.dylib 0x2d060 _objc_fatalv(unsigned long long, unsigned long long, char const*, char*) + 30 5 libobjc.A.dylib 0x5a60 weak_register_no_lock + 392 6 libobjc.A.dylib 0xb3e0 objc_initWeak + 400 7 UIKitCore 0x4f93f0 -[UITableView _configureCellPrefetchingHandlers] + 288 8 UIKitCore 0x17b500 -[UITableView layoutSubviews] + 296 9 UIKitCore 0x18b844 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2592 10 QuartzCore 0x401c0 CA::Layer::layout_if_needed(CA::Transaction*) + 532 11 QuartzCore 0x325fc CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 136 12 QuartzCore 0x46f70 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 452 13 QuartzCore 0x4fe78 CA::Transaction::commit() + 704 14 QuartzCore 0x31d7c CA::Transaction::flush_as_runloop_observer(bool) + 88 15 UIKitCore 0x53d9d8 _UIApplicationFlushCATransaction + 72 16 UIKitCore 0x7d8084 _UIUpdateSequenceRun + 84 17 UIKitCore 0xe5dcb0 schedulerStepScheduledMainSection + 144 18 UIKitCore 0xe5d478 runloopSourceCallback + 92 19 CoreFoundation 0xbbf04 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 20 CoreFoundation 0xccc90 __CFRunLoopDoSource0 + 208 21 CoreFoundation 0x6184 __CFRunLoopDoSources0 + 268 22 CoreFoundation 0xbb4c __CFRunLoopRun + 828 23 CoreFoundation 0x1f6b8 CFRunLoopRunSpecific + 600 24 GraphicsServices 0x1374 GSEventRunModal + 164 25 UIKitCore 0x513e88 -[UIApplication _run] + 1100 26 UIKitCore 0x2955ec UIApplicationMain + 364 27 libswiftUIKit.dylib 0x30ecc UIApplicationMain(_:_:_:_:) + 104 28 AbhiBus 0x81fc main + 12 (main.swift:12) 29 ??? 0x10211dce4 (Missing)
Replies
1
Boosts
0
Views
1.2k
Activity
May ’22
API for rotating display
Greetings, Recently I want to make a application that is capable of rotating my external display. I found these related APIs CGBeginDisplayConfiguration, CGDisplayRotation. The first one let me change height and width of display, but not the rotation angle, and the second one only shows the current rotation angle. I wonder is it possible for us to change the rotation of display someway through API? Thank you, Kuroame
Replies
0
Boosts
0
Views
855
Activity
May ’22
Exception Type: SIGSEGV QuartzCore crash
Many of our users experienced this crash, but we were unable to reproduce it crash
Replies
1
Boosts
0
Views
1.5k
Activity
May ’22
Core Data
Hi, please how can I save an array of Uiimages into core data as one of my attributes? And is it possible preload data into core data?
Replies
0
Boosts
0
Views
1.3k
Activity
Apr ’22
How to use IOSurface instead of NSOpenGLPixelBuffer on Mac? How to use GL_EXT_framebuffer_object instead?
I used to have a project that used Quartz Composer and OpenGL, but Xcode 13 has deprecated these two components, which caused me to fail to get off-screen images during video production. The previous code to create the OpenGLContext is as follows: (id) initOffScreenOpenGLPixelsWide:(unsigned)width pixelsHigh:(unsigned)height { //Check parameters - Rendering at sizes smaller than 16x16 will likely produce garbage if((width < 16) || (height < 16)) { [self release]; return nil; } self = [super init]; if(self != nil) {         NSOpenGLPixelFormatAttribute pixattributes[] = {             NSOpenGLPFADoubleBuffer,             NSOpenGLPFANoRecovery,             NSOpenGLPFAAccelerated,             NSOpenGLPFADepthSize, 24,             (NSOpenGLPixelFormatAttribute) 0         };         _pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:pixattributes]; //Create the OpenGL context to render with (with color and depth buffers) _openGLContext = [[NSOpenGLContext alloc] initWithFormat:_pixelFormat shareContext:nil]; if(_openGLContext == nil) { DDLogInfo(@"Cannot create OpenGL context"); [self release]; return nil; }                  //Create the OpenGL pixel buffer to render into         NSOpenGLPixelBuffer* glPixelBuffer = [[NSOpenGLPixelBuffer alloc] initWithTextureTarget:GL_TEXTURE_RECTANGLE_EXT    textureInternalFormat:GL_RGBA textureMaxMipMapLevel:0 pixelsWide:width pixelsHigh:height];         if(glPixelBuffer == nil) {             DDLogInfo(@"Cannot create OpenGL pixel buffer");             [self release];             return nil;         }         [_openGLContext setPixelBuffer:glPixelBuffer cubeMapFace:0 mipMapLevel:0 currentVirtualScreen:[_openGLContext currentVirtualScreen]];                  //Destroy the OpenGL pixel buffer         [glPixelBuffer release];          NSMutableDictionary* attributes = [NSMutableDictionary dictionary];         [attributes setObject:[NSNumber numberWithUnsignedInt:k32BGRAPixelFormat] forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey]; [attributes setObject:[NSNumber numberWithUnsignedInt:width] forKey:(NSString*)kCVPixelBufferWidthKey]; [attributes setObject:[NSNumber numberWithUnsignedInt:height] forKey:(NSString*)kCVPixelBufferHeightKey]; //Create buffer pool to hold our frames OSErr theError = CVPixelBufferPoolCreate(kCFAllocatorDefault, NULL, (CFDictionaryRef)attributes, &_bufferPool); if(theError != kCVReturnSuccess)  { DDLogInfo(@"CVPixelBufferPoolCreate() failed with error %i", theError); [self release]; return nil; } }     /*      *A context is current on a per-thread basis. Multiple threads must serialize calls into the same context object.      */     [self.openGLContext makeCurrentContext]; return self; } By creating an NSOpenGLPixelBuffer object, and then setting the pixelbuffer of NSOpenGLContext, but in Xcode13, NSOpenGLPixelBuffer cannot be created successfully. Looking at the help documentation, it is recommended to use GL_EXT_framebuffer_object instead. So I tried the following code::         //RGBA8 RenderBuffer, 24 bit depth RenderBuffer, 256x256         glGenFramebuffersEXT(1, &fb);         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);         //Create and attach a color buffer                  glGenRenderbuffersEXT(1, &color_rb);         //We must bind color_rb before we call glRenderbufferStorageEXT         glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, color_rb);         //The storage format is RGBA8         glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA, width, height);         //Attach color buffer to FBO         glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, color_rb);         //-------------------------                  glGenRenderbuffersEXT(1, &depth_rb);         glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth_rb);         glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, width, height);         //-------------------------         //Attach depth buffer to FBO         glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb);         //-------------------------         //Does the GPU support current FBO configuration?         GLenum status;         status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);         switch(status)         {             case GL_FRAMEBUFFER_COMPLETE_EXT:                 DDLogInfo(@"gl no problem");                 break;             default:                 DDLogInfo(@"error");                 break;         }                  //-------------------------         //and now you can render to the FBO (also called RenderBuffer)         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); When running the program we can get the 'gl no problem' log. However, when reading off-screen image data, although glGetError does not return an error code, I can only read a black image. In previous versions, a QCRenderer rendered image could be successfully obtained. Reading off-screen images is implemented as follows: (CVPixelBufferRef) readPixelBuffer {     // Create pixel buffer from pixel buffer pool     CVPixelBufferRef bufferRef;     OSErr theError = CVPixelBufferPoolCreatePixelBuffer(kCFAllocatorDefault, _bufferPool, &bufferRef);     if(theError) {         DDLogInfo(@"CVPixelBufferPoolCreatePixelBuffer() failed with error %i", theError);         return nil;     }     theError = CVPixelBufferLockBaseAddress(bufferRef, 0); if(theError) { DDLogInfo(@"CVPixelBufferLockBaseAddress() failed with error %i", theError); return nil; } void* bufferPtr = CVPixelBufferGetBaseAddress(bufferRef);     size_t width = CVPixelBufferGetWidth(bufferRef);     size_t height = CVPixelBufferGetHeight(bufferRef); size_t bufferRowBytes = CVPixelBufferGetBytesPerRow(bufferRef);     CGLContextObj cgl_ctx = [_openGLContext CGLContextObj]; CGLLockContext(cgl_ctx);     //Read pixels back from the OpenGL pixel buffer in ARGB 32 bits format - For extra safety, we save / restore the OpenGL states we change     GLint save; glGetIntegerv(GL_PACK_ROW_LENGTH, &save); glPixelStorei(GL_PACK_ROW_LENGTH, (int)bufferRowBytes / 4); glReadPixels(0, 0, (GLsizei)width, (GLsizei)height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, bufferPtr);     flipImage(bufferPtr, width, height, bufferRowBytes);     glPixelStorei(GL_PACK_ROW_LENGTH, save); CGLUnlockContext(cgl_ctx);     GLenum code = glGetError(); if(code) return nil; CVPixelBufferUnlockBaseAddress(bufferRef, 0);     return bufferRef; } Ask an expert how to solve this problem.
Replies
0
Boosts
0
Views
1.3k
Activity
Apr ’22
occasional crashes in CGContext.drawPDFPage
Hi,in our app we render PDF pages with a CATiledLayer to screen. We have occasional crashes mostly on iPads. Every time it crashes there are two or three concurrent threads rendering the page. I'm not able to reproduce it.Any idea how to fix this?Code looks like this: override func draw(_ layer: CALayer, in ctx: CGContext) { guard let page = self.page else { return } ctx.setFillColor(red: 1.0,green: 1.0,blue: 1.0,alpha: 1.0) ctx.fill(ctx.boundingBoxOfClipPath) let layerSize = layer.bounds.size // Flip the context so that the PDF page is rendered right side up. ctx.translateBy(x: 0.0, y: layerSize.height) ctx.scaleBy(x: 1.0, y: -1.0) let pageMediaBox = page.getBoxRect(.mediaBox) let fillWithPDFPageVerticalProportion = layerSize.height / pageMediaBox.height let fillWithPDFPageHorizontalProportion = layerSize.width / pageMediaBox.width let fillWithPDFPageProportion = min(fillWithPDFPageVerticalProportion, fillWithPDFPageHorizontalProportion) ctx.translateBy( x: -(pageMediaBox.width * fillWithPDFPageProportion - layerSize.width) / 2, y: -(pageMediaBox.height * fillWithPDFPageProportion - layerSize.height) / 2 ) ctx.scaleBy(x: fillWithPDFPageProportion, y: fillWithPDFPageProportion) ctx.drawPDFPage(page) }This is a stack trace from the crashing thread:#8. Crashed: com.apple.root.default-qos0 libobjc.A.dylib 0x185a8c1a0 objc_retain + 161 ImageIO 0x1888dd5cc IIOImageRead::IIOImageRead(CGDataProvider*, bool) + 882 ImageIO 0x1888df93c CGImageReadCreateWithProvider + 1963 ImageIO 0x18874ac6c IIOImageSource::IIOImageSource(CGDataProvider*, IIODictionary*) + 964 ImageIO 0x18874ec50 CGImageSourceCreateWithDataProvider + 1725 CoreGraphics 0x18803a464 CGImageCreateWithJPEGDataProvider3 + 846 CoreGraphics 0x187fb7264 create_image_for_image + 1887 CoreGraphics 0x187fb713c CGPDFImageCreateImage + 1848 CoreGraphics 0x1880256f8 CGPDFDrawingContextDrawImage + 409 CoreGraphics 0x1880de03c op_Do + 10410 CoreGraphics 0x1882e6684 pdf_scanner_handle_xname + 14411 CoreGraphics 0x1882e5f0c CGPDFScannerScan + 36812 CoreGraphics 0x1882f0170 CGPDFDrawingContextDrawPage + 51613 CoreGraphics 0x1880c0a04 pdf_page_draw_in_context + 13214 CoreGraphics 0x187fa763c CGContextDrawPDFPageWithDrawingCallbacks + 7615 CoreGraphics 0x187fa7310 CGContextDrawPDFPage + 3216 myApp 0x1009e8cf0 specialized PDFTiledView.draw(CALayer, in : CGContext) -&gt; () (PDFTiledView.swift:59)17 myApp 0x1009e88ec @objc PDFTiledView.draw(CALayer, in : CGContext) -&gt; () (PDFTiledView.swift)18 QuartzCore 0x18a86b51c -[CALayer drawInContext:] + 29619 QuartzCore 0x18a79c780 tiled_layer_render(_CAImageProvider*, unsigned int, unsigned int, unsigned int, unsigned int, void*) + 153220 QuartzCore 0x18a836448 CAImageProviderThread(unsigned int*, bool) + 81221 libdispatch.dylib 0x1861a6a14 _dispatch_client_callout + 1622 libdispatch.dylib 0x1861adbc8 _dispatch_queue_override_invoke$VARIANT$mp + 71623 libdispatch.dylib 0x1861b3cf4 _dispatch_root_queue_drain + 60024 libdispatch.dylib 0x1861b3a38 _dispatch_worker_thread3 + 12025 libsystem_pthread.dylib 0x18644f06c _pthread_wqthread + 126826 libsystem_pthread.dylib 0x18644eb6c start_wqthread + 4There are two threads with this stack trace:#9. com.apple.root.default-qos0 libsystem_kernel.dylib 0x18633c138 __psynch_mutexwait + 81 libsystem_pthread.dylib 0x186453660 _pthread_mutex_lock_wait + 962 libsystem_pthread.dylib 0x1864535a4 _pthread_mutex_lock_slow$VARIANT$mp + 2643 CoreGraphics 0x187fb70ac CGPDFImageCreateImage + 404 CoreGraphics 0x1880256f8 CGPDFDrawingContextDrawImage + 405 CoreGraphics 0x1880de03c op_Do + 1046 CoreGraphics 0x1882e6684 pdf_scanner_handle_xname + 1447 CoreGraphics 0x1882e5f0c CGPDFScannerScan + 3688 CoreGraphics 0x1882f0170 CGPDFDrawingContextDrawPage + 5169 CoreGraphics 0x1880c0a04 pdf_page_draw_in_context + 13210 CoreGraphics 0x187fa763c CGContextDrawPDFPageWithDrawingCallbacks + 7611 CoreGraphics 0x187fa7310 CGContextDrawPDFPage + 3212 myApp 0x1009e8cf0 specialized PDFTiledView.draw(CALayer, in : CGContext) -&gt; () (PDFTiledView.swift:59)13 myApp 0x1009e88ec @objc PDFTiledView.draw(CALayer, in : CGContext) -&gt; () (PDFTiledView.swift)14 QuartzCore 0x18a86b51c -[CALayer drawInContext:] + 29615 QuartzCore 0x18a79c780 tiled_layer_render(_CAImageProvider*, unsigned int, unsigned int, unsigned int, unsigned int, void*) + 153216 QuartzCore 0x18a836448 CAImageProviderThread(unsigned int*, bool) + 81217 libdispatch.dylib 0x1861a6a14 _dispatch_client_callout + 1618 libdispatch.dylib 0x1861adbc8 _dispatch_queue_override_invoke$VARIANT$mp + 71619 libdispatch.dylib 0x1861b3cf4 _dispatch_root_queue_drain + 60020 libdispatch.dylib 0x1861b3a38 _dispatch_worker_thread3 + 12021 libsystem_pthread.dylib 0x18644f06c _pthread_wqthread + 126822 libsystem_pthread.dylib 0x18644eb6c start_wqthread + 4Thanks,Snert
Replies
2
Boosts
0
Views
2.9k
Activity
Dec ’21
Touch area does not matched with Image after SubImage is sized up
If I enlarge up the Image 8x with pinch out gesture, there is a phenomenon that displaying area of the subimage and the touchable area of the sub image is not matched I think it looks like the touchable area has been moved from the image area to the top left by 20dp. Please guide me on how to exactly match the displayed area and the touched area of the subimage on the ImageView I set the autoresizesSubViews property of ImageView to true, and Subimages were scaled with CATransform3DMakeScale when pinched out.
Replies
0
Boosts
0
Views
547
Activity
Nov ’21
drawing into an existing CGImage
Ok, maybe I'm hung up on Mac OS X design patterns, just tell me if that's the case.the problem:I need to draw a line on an existing CGImage.There's no LockFocus methods for CGImage, There's no obvious documented way to get the already created Context of a Bitmap in the CGImage. There's no obvious or explicit code explaining the procedure.I have the reference to the image, I have the two points that make up the line, I know all of the code to draw that line... I just cannot make the context associated to that image, the current context. What gives? what is the design pattern? Please tell me where I can read about this.
Replies
3
Boosts
0
Views
2.8k
Activity
Nov ’21
WKWebView play video crash on some Model
When I opened the video in HTML, it crashed when I started playing it。 Here is my app crash report: 0 CoreFoundation __HALT + 2 arrow_right 1 QuartzCore CA::Layer::setter(unsigned int, _CAValueType, void const*) + 252 2 QuartzCore[CALayer setBackgroundColor:] + 56 3 QuartzCore[CAStateSetValue apply:] + 620 4 QuartzCore[CAStateController setState:ofLayer:transitionSpeed:] + 1364 5 AVKit[AVMicaPackage transitionToStateWithName:onLayer:] + 144 6 AVKit[AVMicaPackage transitionToStateWithName:] + 92 7 AVKit[AVMicaPackage _setState:] + 108 8 AVKit[AVMicaPackage setState:color:] + 116 9 AVKit[AVPlaybackControlsRoutePickerView updateButtonAppearance] + 204 10 AVKit[AVRoutePickerView layoutSubviews] + 632 11 UIKitCore[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2500 12 QuartzCore[CALayer layoutSublayers] + 296 13 QuartzCore CA::Layer::layout_if_needed(CA::Transaction*) + 524 14 QuartzCore CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 144 15 QuartzCore CA::Context::commit_transaction(CA::Transaction*, double, double*) + 416 16 QuartzCore CA::Transaction::commit() + 732 17 QuartzCore CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 96 18 CoreFoundation CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 36 19 CoreFoundation __CFRunLoopDoObservers + 576 20 CoreFoundation __CFRunLoopRun + 1056 21 CoreFoundation CFRunLoopRunSpecific + 600 22 GraphicsServices GSEventRunModal + 164 23 UIKitCore[UIApplication _run] + 1072 24 UIKitCore UIApplicationMain + 168 25 AXNews main.m - 第 15 行 main + 15 26 libdyld.dylib start + 4
Replies
3
Boosts
0
Views
1.4k
Activity
Oct ’21
UIImage from snapshot view?
On iOS, I'm trying to convert the contents of a view produced by snapshotView(afterScreenUpdates:) into a UIImage. At the point where I'm trying to do this, I no longer have the underlying objects that were rendered into the snapshot - I only have the snapshot view.Although this snapshot view displays correctly on the device screen at all times, I seem to be unable to convert it to an image to save to disk.For example, say I do something like: let ssView = someView.snapshotView(afterScreenUpdates:true)And then later, I want to convert ssView to a UIImage. I have tried all the usual patterns that work with other (non-snapshot) views such as: UIGraphicsBeginImageContext(ssView.frame.size) ssView.drawHierarchy(in: ssView.bounds, afterScreenUpdates: true) let image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext()or let renderer = UIGraphicsImageRenderer(size: ssView.frame.size) let image = renderer.image { context in return ssView.layer.render(in: context.cgContext) }And many other variations... I've also tried to render the hierarchy from superviews of the snapshot view but no matter what I try, it doesn't work. Attempting to capture the snapshot view directly produces a blank image and if the parent view is captured, the portion of the screen where the snapshot view resides is blank.Does anyone have any idea how to make this work?Thanks,David
Replies
2
Boosts
0
Views
3.3k
Activity
Aug ’21