RESOLVED INVALID 46991
Flickering with div compositing using CAOpenGLLayer in non-out-of-process plugin
https://bugs.webkit.org/show_bug.cgi?id=46991
Summary Flickering with div compositing using CAOpenGLLayer in non-out-of-process plugin
Dan Webb
Reported 2010-10-01 09:55:59 PDT
Created attachment 69476 [details] Simple plugin that exhibits the flickering behavior Hello, The combination of the following is causing flickering problems for my plugin: 1. Using CAOpenGLLayer for rendering. 2. DIVs in front of my plugin, which are properly composited (yay!) with CoreAnimation layers in the latest version of Safari/WebKit. 3. Non-out-of-process plugins, which implies 32-bit Safari. When a DIV appear or disappears in front of the plugin, the plugin renders a white image for a moment. The result is a very annoying flicker whenever a DIV comes or goes. My plugin is the Google Earth plugin, which relies heavily on being able to display a DIV in front of the Earth image (for the info balloon at maps.google.com, when you click on a placemark). I've attached a very simple Xcode project that exhibits the behavior. The CAOpenGLLayer subclass simply creates a texture and renders it to the context. When you push the Hide/Show button on the enclosed web page, it hides/shows the DIV, and you will see the flash of white when this happens. I've only tested it on 10.6; not sure what happens on 10.5. Be sure to test it in out-of-process mode, which means 32-bit Safari/WebKit (Get Info and click the "Open in 32-bit mode" checkbox). I tried it in the latest WebKit build, and the problem is still there. Any help is appreciated. I suspect I'm the only NPAPI plugin developer to run into this problem.
Attachments
Simple plugin that exhibits the flickering behavior (72.89 KB, application/octet-stream)
2010-10-01 09:55 PDT, Dan Webb
no flags
Plugin test case that builds with latest WebKit (73.36 KB, application/zip)
2010-10-04 13:08 PDT, Dan Webb
no flags
Simon Fraser (smfr)
Comment 1 2010-10-01 10:07:57 PDT
Plugin does not build: /Users/smfr/Downloads/NetscapeCoreAnimationOpenGLPlugin/main.m:120: error: expected declaration specifiers or '...' before 'int16' /Users/smfr/Downloads/NetscapeCoreAnimationOpenGLPlugin/main.m:120: error: conflicting types for 'NPP_New' /System/Library/Frameworks/WebKit.framework/Headers/npapi.h:771: error: previous declaration of 'NPP_New' was here /Users/smfr/Downloads/NetscapeCoreAnimationOpenGLPlugin/main.m:125: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'NPP_WriteReady' /Users/smfr/Downloads/NetscapeCoreAnimationOpenGLPlugin/main.m:126: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'NPP_Write' /Users/smfr/Downloads/NetscapeCoreAnimationOpenGLPlugin/main.m:129: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'NPP_HandleEvent' /Users/smfr/Downloads/NetscapeCoreAnimationOpenGLPlugin/main.m: In function 'NP_GetEntryPoints': /Users/smfr/Downloads/NetscapeCoreAnimationOpenGLPlugin/main.m:151: warning: assignment from incompatible pointer type /Users/smfr/Downloads/NetscapeCoreAnimationOpenGLPlugin/main.m: At top level: /Users/smfr/Downloads/NetscapeCoreAnimationOpenGLPlugin/main.m:173: error: expected declaration specifiers or '...' before 'int16' /Users/smfr/Downloads/NetscapeCoreAnimationOpenGLPlugin/main.m:174: error: conflicting types for 'NPP_New' /System/Library/Frameworks/WebKit.framework/Headers/npapi.h:771: error: previous declaration of 'NPP_New' was here /Users/smfr/Downloads/NetscapeCoreAnimationOpenGLPlugin/main.m:238: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'NPP_WriteReady' /Users/smfr/Downloads/NetscapeCoreAnimationOpenGLPlugin/main.m:243: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'NPP_Write' /Users/smfr/Downloads/NetscapeCoreAnimationOpenGLPlugin/main.m:261: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'NPP_HandleEvent' {standard input}:262:non-relocatable subtraction expression, "L___stack_chk_guard$non_lazy_ptr" minus "L00000000001$pb" {standard input}:262:symbol: "L___stack_chk_guard$non_lazy_ptr" can't be undefined in a subtraction expression {standard input}:248:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_0" minus "L00000000001$pb" {standard input}:248:symbol: "L_OBJC_SELECTOR_REFERENCES_0" can't be undefined in a subtraction expression {standard input}:244:non-relocatable subtraction expression, "L_OBJC_CLASS_MyLayer" minus "L00000000001$pb" {standard input}:244:symbol: "L_OBJC_CLASS_MyLayer" can't be undefined in a subtraction expression {standard input}:227:non-relocatable subtraction expression, "LC5" minus "L00000000001$pb" {standard input}:227:symbol: "LC5" can't be undefined in a subtraction expression {standard input}:224:non-relocatable subtraction expression, "LC5" minus "L00000000001$pb" {standard input}:224:symbol: "LC5" can't be undefined in a subtraction expression {standard input}:219:non-relocatable subtraction expression, "LC4" minus "L00000000001$pb" {standard input}:219:symbol: "LC4" can't be undefined in a subtraction expression {standard input}:216:non-relocatable subtraction expression, "LC4" minus "L00000000001$pb" {standard input}:216:symbol: "LC4" can't be undefined in a subtraction expression {standard input}:211:non-relocatable subtraction expression, "LC3" minus "L00000000001$pb" {standard input}:211:symbol: "LC3" can't be undefined in a subtraction expression {standard input}:208:non-relocatable subtraction expression, "LC5" minus "L00000000001$pb" {standard input}:208:symbol: "LC5" can't be undefined in a subtraction expression {standard input}:203:non-relocatable subtraction expression, "LC2" minus "L00000000001$pb" {standard input}:203:symbol: "LC2" can't be undefined in a subtraction expression {standard input}:200:non-relocatable subtraction expression, "LC4" minus "L00000000001$pb" {standard input}:200:symbol: "LC4" can't be undefined in a subtraction expression {standard input}:195:non-relocatable subtraction expression, "LC5" minus "L00000000001$pb" {standard input}:195:symbol: "LC5" can't be undefined in a subtraction expression {standard input}:192:non-relocatable subtraction expression, "LC3" minus "L00000000001$pb" {standard input}:192:symbol: "LC3" can't be undefined in a subtraction expression {standard input}:187:non-relocatable subtraction expression, "LC4" minus "L00000000001$pb" {standard input}:187:symbol: "LC4" can't be undefined in a subtraction expression {standard input}:184:non-relocatable subtraction expression, "LC2" minus "L00000000001$pb" {standard input}:184:symbol: "LC2" can't be undefined in a subtraction expression {standard input}:179:non-relocatable subtraction expression, "LC3" minus "L00000000001$pb" {standard input}:179:symbol: "LC3" can't be undefined in a subtraction expression {standard input}:176:non-relocatable subtraction expression, "LC3" minus "L00000000001$pb" {standard input}:176:symbol: "LC3" can't be undefined in a subtraction expression {standard input}:171:non-relocatable subtraction expression, "LC2" minus "L00000000001$pb" {standard input}:171:symbol: "LC2" can't be undefined in a subtraction expression {standard input}:168:non-relocatable subtraction expression, "LC2" minus "L00000000001$pb" {standard input}:168:symbol: "LC2" can't be undefined in a subtraction expression {standard input}:111:non-relocatable subtraction expression, "LC1" minus "L00000000001$pb" {standard input}:111:symbol: "LC1" can't be undefined in a subtraction expression {standard input}:104:non-relocatable subtraction expression, "LC1" minus "L00000000001$pb" {standard input}:104:symbol: "LC1" can't be undefined in a subtraction expression {standard input}:97:non-relocatable subtraction expression, "LC0" minus "L00000000001$pb" {standard input}:97:symbol: "LC0" can't be undefined in a subtraction expression {standard input}:90:non-relocatable subtraction expression, "LC0" minus "L00000000001$pb" {standard input}:90:symbol: "LC0" can't be undefined in a subtraction expression {standard input}:70:non-relocatable subtraction expression, "L___stack_chk_guard$non_lazy_ptr" minus "L00000000001$pb" {standard input}:70:symbol: "L___stack_chk_guard$non_lazy_ptr" can't be undefined in a subtraction expression {standard input}:unknown:Undefined local symbol L___stack_chk_guard$non_lazy_ptr {standard input}:unknown:Undefined local symbol LC0 {standard input}:unknown:Undefined local symbol LC1 {standard input}:unknown:Undefined local symbol LC2 {standard input}:unknown:Undefined local symbol LC3 {standard input}:unknown:Undefined local symbol LC4 {standard input}:unknown:Undefined local symbol LC5 {standard input}:unknown:Undefined local symbol L_OBJC_CLASS_MyLayer {standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_0
Dan Webb
Comment 2 2010-10-01 12:19:04 PDT
Not sure why it's not building for you. I adapted this project from WebKit/WebKitExamplePlugins/NetscapeCoreAnimationPlugin. I'm building with the 10.6 SDK. Your build seems to be missing the int16 type, which is defined in /System/Library/Frameworks/WebKit.framework/Headers/npapi.h. Is yours pulling in a different npapi.h?
Simon Fraser (smfr)
Comment 3 2010-10-01 13:11:27 PDT
Mine has int16_t, not int16.
Dan Webb
Comment 4 2010-10-01 14:59:00 PDT
Looks like you've got the latest WebKit npapi.h installed. I'll see if I can update the code to match. (It would be nice if the developers who change npapi.h would also update the samples.)
Dan Webb
Comment 5 2010-10-04 13:08:12 PDT
Created attachment 69673 [details] Plugin test case that builds with latest WebKit Here's the test case that builds without errors against the latest WebKit.
Dan Webb
Comment 6 2010-10-05 10:35:49 PDT
My test case now builds with the latest WebKit. Any ideas what's causing the flickering problem? I took a look at the code, but not being familiar with it, I saw nothing immediately obvious that would cause it. We plan to ship the Earth plugin soon that uses IOSurface, and assuming this is indeed a bug in WebKit, I don't expect it to be fixed and pushed out to all users before we ship. So I'm planning on doing some kind of workaround in the meantime. Something skanky like checking for in-process plugins (not sure how to yet) and using the slower CG model for rendering instead of IOSurface. Any better ideas are welcome.
Mark Rowe (bdash)
Comment 7 2010-10-05 13:42:15 PDT
Simon Fraser (smfr)
Comment 8 2010-10-05 13:57:02 PDT
I'll take a look.
Simon Fraser (smfr)
Comment 9 2010-10-05 14:19:33 PDT
It flickers because the 'contents' property of your layer is getting animated by CoreAnimation (when the layer hierarchy changes). You can easily fix this in the plugin: --- main copy.m 2010-10-05 14:08:48.000000000 -0700 +++ main.m 2010-10-05 14:17:35.000000000 -0700 @@ -287,6 +287,11 @@ case NPPVpluginCoreAnimationLayer: if (!obj->layer) { obj->layer = [[[MyLayer alloc] init] retain]; + + NSDictionary *actions = [NSDictionary dictionaryWithObjectsAndKeys: + [NSNull null], @"contents", + nil]; + [obj->layer setActions:actions]; } // Make sure to return a retained layer
Dan Webb
Comment 10 2010-10-05 15:29:32 PDT
Thanks Simon! That did the trick. My CoreAnimation mojo isn't strong enough to handle problems like this. Strange that the problem didn't occur in out-of-process plugins.
Simon Fraser (smfr)
Comment 11 2010-10-05 15:45:34 PDT
I think with OOP plugins there's an extra layer that insulates your layer from hierarchy changes.
Note You need to log in before you can comment on or make changes to this bug.