Closed Bug 582012 Opened 15 years ago Closed 15 years ago

getstringidentifier() returns different NPIdentifiers (OOPP)

Categories

(Core Graveyard :: Plug-ins, defect)

x86
Windows XP
defect
Not set
normal

Tracking

(blocking2.0 beta3+, blocking1.9.2 -, status1.9.2 .9-fixed)

RESOLVED FIXED
Tracking Status
blocking2.0 --- beta3+
blocking1.9.2 --- -
status1.9.2 --- .9-fixed

People

(Reporter: amasson, Assigned: benjamin)

References

Details

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:2.0b1) Gecko/20100630 Firefox/4.0b1 ( .NET CLR 3.5.30729) Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:2.0b1) Gecko/20100630 Firefox/4.0b1 ( .NET CLR 3.5.30729) I have implemented a plugin that call the function getstringidentifier() provided by the browser to convert a method name to a NPIdentifier. When a method is invoked on the plugin, the plugin compares the input NPIdentifier to cached NPIdentifiers for all methods of my object to find the requested method. It has worked fine in FF 2, 3, 3.5, 3.6. In Firefox 4.0b1, if the the OOPP (out-of-process plugin) mode is disabled, it also works. But if OOPP is enabled (default), it doesn't work well because sometimes the input NPIdentifier doesn't match any IDs, especially just after browser startup. After some debugging, I have discovered that getstringidentifier() returns different NPIdentifiers for the _same_ method name at different times, in a single browser session. Reproducible: Sometimes Steps to Reproduce: Start Firefox. Open a page with 1 plugin instance defined in the HTML source. Press a button that calls a scriptable method. (I cannot provide my plugin.) Actual Results: JS cannot call the plugin method. An error "yyyy.xxxx is not a function" is displayed in the JS console. Expected Results: JS can call the plugin method. NPIdentifiers for the same method name should not change during a single session.
In order to help us reproduce this issue, can you help provide a more exact sequence of events, and the exact APIs your plugin is calling? -> NP_Initialize -< NPN_GetStringIdentifiers Do you call NPN_GetStringIdentifiers here, or sometime later, perhaps during NPP_New or the first NPRuntime call? Are you calling NPN_GetStringIdentifier, or NPN_GetStringIdentifiers?
blocking2.0: --- → ?
I am using a very similar technique in my plugins, maybe with two differences: I only ask for a single identifier at a time (NPN_GetStringIdentifier), and I only do that lazyly on first call/access to a scriptable function or property. I have, so far, been unable to reproduce the problem, but maybe it was just luck.
(In reply to comment #1) I have reproduced the same kind of problem without NPIdentifier caching, in the HasMethod() provided by my scriptable object: bool KPluginProxy::HasMethod(NPIdentifier methodID) { string methodStr = NPGetMethodName(methodID); // // wrapper around GetNPNFuncs()->utf8fromidentifier; NPIdentifier methodID2 = (*GetNPNFuncs()->getstringidentifier)(methodStr.c_str()); if (methodID != methodID2) { // !!! MessageBox(...); } ... Just after browser startup, if I call the method from JS, the MessageBox is displayed. However 'methodStr' is correct. After a page refresh, it works as expected.
Indeed, when we get identifiers from the browser we're not adding them to the hashtable, which causes us to create a new one instead of re-using the one we want. Many plugins call NPN_GetStringIdentifiers first, during NPP_New or when you create an object type, so they don't have this problem. But I'm not sure that Silverlight or Flash won't be subtly broken by this bug, so I think we should take this on branches as well.
Assignee: nobody → benjamin
Status: UNCONFIRMED → ASSIGNED
blocking1.9.2: --- → ?
blocking2.0: ? → beta3+
Ever confirmed: true
Attachment #460542 - Flags: review?(bent.mozilla)
Comment on attachment 460542 [details] [diff] [review] Add them to the maps, rev. 1 Wow. Oops.
Attachment #460542 - Flags: review?(bent.mozilla) → review+
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Comment on attachment 460542 [details] [diff] [review] Add them to the maps, rev. 1 a=LegNeato for 1.9.2.9.
Attachment #460542 - Flags: approval1.9.2.9? → approval1.9.2.9+
blocking1.9.2: ? → -
Depends on: 584156
I believe this bug has caused a permanent orange on Mac on the 1.9.2 branch, see bug 584156 for details.
There is absolutely no way this caused a problem on mac-1.9.2, since that code isn't even *built* on mac-1.9.2 ;-)
No longer depends on: 584156
Blocks: 562051
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: