2
votes

I am creating a PDF Application for OSX. I am using PDFKit framework from Apple to do this.

However, when running the application on Mavericks (OSX 10.9) the PDF view is always drawn in front! This means that views that on 10.8 where shown in front of the pdf view now are drawn behind it! This was not the case for OSX 10.8 or below.

I have tried to build against 10.9 with the 10.9 sdk in XCode 5 but without any luck. The application should preferably support 10.7 and I have previously used the 10.8 sdk in XCode 4.

This is how I've structured my views:

- PDF View
  - View 1
- View 2

where the first view is rendered first (below others).

They are drawn this way in OSX 10.8 and below:

  1. View 2
  2. View 1
  3. PDF View

But in OSX 10.9 the are drawn:

  1. View 1
  2. PDF View
  3. View 2

Any ideas?

Here is the view structure on 10.8 from [parentView _subtreeDescription]:

$0 = 0x000000010e918740 [   A      LU ] h=--- v=--- NSView 0x1025de1e0 f=(0,1,809,755) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
  [   AF     LU ] h=-&- v=&-- PSMTabBarControl 0x11963b330 f=(0,733,809,22) b=(-) TIME drawRect: min/mean/max 0.41/0.54/0.71 ms
    [  HAF     LU ] h=&-- v=--- PSMOverflowPopUpButton 0x119427640 f=(781,0,14,22) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
    [  HAF     LU ] h=--- v=--- PSMRolloverButton 0x11943db20 f=(0,0,0,0) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
  [    F O   LU ] h=-&- v=-&- NSTabView 0x1025ec850 f=(0,0,809,718) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
    [      O   LU ] h=-&- v=-&- IBEditPDFView 0x1051233f0 f=(0,0,809,718) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
      [   AF O   LU ] h=--- v=--- PDFViewScrollView 0x105124230 f=(0,0,809,718) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
        [   AF OGP LU ] h=--- v=--- NSClipView 0x105124530 f=(0,0,809,718) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
          [   AF O   LU ] h=--- v=--- PDFMatteView 0x105123670 f=(0,0,809,718) b=(-) TIME drawRect: min/mean/max 0.23/0.28/0.39 ms
            [   A      LU ] h=--- v=--- PDFDisplayView 0x105103c50 f=(148,0,513,718) b=(-) TIME drawRect: min/mean/max 0.27/1.98/9.80 ms
            //...
        [  HAF     LU ] h=--- v=--- NSScroller 0x1004a09f0 f=(-100,-100,15,755) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
  [   AF     LU ] h=--& v=&-& NSButton 0x10258dc70 f=(20,328,40,60) b=(-) TIME drawRect: min/mean/max 0.15/0.71/2.33 ms
  [   AF     LU ] h=&-- v=&-& NSButton 0x11945ab10 f=(749,328,40,60) b=(-) TIME drawRect: min/mean/max 0.10/9.84/56.55 ms

A=autoresizesSubviews, C=canDrawConcurrently, D=needsDisplay, F=flipped, G=gstate, H=hidden (h=by ancestor), L=needsLayout (l=child needsLayout), U=needsUpdateConstraints (u=child needsUpdateConstraints), O=opaque, P=preservesContentDuringLiveResize, S=scaled/rotated, W=wantsLayer (w=ancestor wantsLayer), #=has surface

And here is the (faulty) Mavericks view structure:

$0 = 0x000000010044c7d0 [   A      LU ] h=--- v=--- NSView 0x114d37760 f=(0,1,2119,1172) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
  [   AF     LU ] h=-&- v=&-- PSMTabBarControl 0x114d2d8a0 f=(0,1150,2119,22) b=(-) TIME drawRect: min/mean/max 0.44/0.70/1.11 ms
    [  HAF     LU ] h=&-- v=--- PSMOverflowPopUpButton 0x114d187c0 f=(2091,0,14,22) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
    [  HAF     LU ] h=--- v=--- PSMRolloverButton 0x114d15770 f=(0,0,0,0) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
  [    F O   LU ] h=-&- v=-&- NSTabView 0x105224c10 f=(0,0,2119,1135) b=(-) TIME drawRect: min/mean/max 0.02/1.00/14.27 ms
    [      O  WlU#] h=-&- v=-&- IBEditPDFView 0x1051226e0 f=(0,0,2119,1135) b=(-) => <_NSViewBackingLayer: 0x10513d330> TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
      [   AF O  wlU ] h=--- v=--- PDFViewScrollView 0x10511ba90 f=(0,0,2119,1135) b=(-) => <_NSViewBackingLayer: 0x1051471d0> TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
        [   AFSO  wlU ] h=--- v=--- PDFCenteringClipView 0x105126540 f=(0,0,2119,1135) b=(-388.943,1.35222e-13,1260.2,675) => <_NSClipViewBackingLayer: 0x1051478f0> TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
          [   AFSO  WLU ] h=--- v=--- PDFMatteView 0x10511a910 f=(0,0,482,675) b=(-) => <_NSViewBackingLayer: 0x10512a970> TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
            [   A S    LU ] h=--- v=--- PDFDisplayView 0x1051240c0 f=(0,0,482,675) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
              //...
        [  HAF    wlU ] h=--- v=--- NSScroller 0x1051f8d00 f=(-100,-100,15,755) b=(-) => <_NSViewBackingLayer: 0x1051f8cd0> TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
  [   AF     LU ] h=--& v=&-& NSButton 0x105224840 f=(20,524,40,60) b=(-) TIME drawRect: min/mean/max 0.12/0.34/11.62 ms
  [   AF     LU ] h=&-- v=&-& NSButton 0x105224470 f=(2059,524,40,60) b=(-) TIME drawRect: min/mean/max 0.09/0.11/0.41 ms

A=autoresizesSubviews, C=canDrawConcurrently, D=needsDisplay, F=flipped, G=gstate, H=hidden (h=by ancestor), L=needsLayout (l=child needsLayout), U=needsUpdateConstraints (u=child needsUpdateConstraints), O=opaque, P=preservesContentDuringLiveResize, S=scaled/rotated, W=wantsLayer (w=ancestor wantsLayer), #=has surface

The does not seems to be any reposition of the order, but the Mavericks has new flags set to some of it's PDFKit views which may cause the problem.

W, w, l and # are new here. Which is "wantsLayer", "ancestor wantsLayer", "child needsLayout" and "has surface".

Any idea how to modify these or any clues on how to solve this?

1
I'm a bit confused by your explanation. What are these other views and how do they relate to the PDFView? - trojanfoe
I have views that are subviews of the pdfkit view (such as pdf markings, annotations, popupmenues). These show just fine in 10.9. But view that are not subviews of the pdfkit view is drawn behind the pdfkit view even if they should be drawn in front of it. (works in 10.8, but now in 10.9) - Sunkas
So why would a view that is not a subview of pdfkit view show in front of it? I still don't understand. - trojanfoe
For example, the PDF view is not covering the entire application, there are side menues and other ares not covered by the pdf view. When I start the application I show a semi-transparent "guide"/tutorial over the entire screen helping the user understand the menues et.c. This view is not a subview of the pdfview. But it should still be drawn in front of it. But it 10.9 the PDF View seems to Always draw itself infront of ever other view, which then is a problem. - Sunkas
How are you setting-up the layers; is the view layer-backed or layer-hosting? - trojanfoe

1 Answers

2
votes

It seems like PDFKit views in Mavericks are using Layer-backed. Setting my overlaying views to the same solved the problem.

[self.nextButton setWantsLayer:YES];
[self.prevButton setWantsLayer:YES];
[self.overlayViewController.view setWantsLayer:YES];