Bug 215293 - REGRESSION(r261159) PokerBros only shows black screen
Summary: REGRESSION(r261159) PokerBros only shows black screen
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords: InRadar
Depends on: 215316
Blocks:
  Show dependency treegraph
 
Reported: 2020-08-07 14:48 PDT by Alex Christensen
Modified: 2020-08-10 11:44 PDT (History)
10 users (show)

See Also:


Attachments
Patch (2.22 KB, patch)
2020-08-07 14:51 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (2.26 KB, patch)
2020-08-10 09:29 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2020-08-07 14:48:39 PDT
REGRESSION(r261159) PokerBros only shows black screen
Comment 1 Alex Christensen 2020-08-07 14:51:09 PDT
Created attachment 406216 [details]
Patch
Comment 2 Keith Miller 2020-08-07 14:56:17 PDT
Comment on attachment 406216 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406216&action=review

r=me with comment.

> Source/JavaScriptCore/runtime/JSObject.cpp:519
> +    static bool isPokerBros = CFEqual(CFBundleGetIdentifier(CFBundleGetMainBundle()), CFSTR("com.kpgame.PokerBros"))

I forget the semantics of this? Is this only run once? I assume so but if not this is probably going to be a perf regression.
Comment 3 Alex Christensen 2020-08-07 14:58:46 PDT
Yes, function scoped static variables are initialized the first time the function is run.  After that there is a read and a branch to check that it is initialized, then the stored value is returned.  There are no atomic operations here, so this should be as little of a perf regression as possible.
Comment 4 Alex Christensen 2020-08-07 15:09:01 PDT
* because of the compile flags we use in WebKit, there are no atomic operations in this check.  Normal C++ does have an atomic check for function scoped static variable initialization.

http://trac.webkit.org/r265392
Comment 5 Radar WebKit Bug Importer 2020-08-07 15:09:32 PDT
<rdar://problem/66702248>
Comment 6 Darin Adler 2020-08-07 16:23:23 PDT
Comment on attachment 406216 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406216&action=review

>> Source/JavaScriptCore/runtime/JSObject.cpp:519
>> +    static bool isPokerBros = CFEqual(CFBundleGetIdentifier(CFBundleGetMainBundle()), CFSTR("com.kpgame.PokerBros"))
> 
> I forget the semantics of this? Is this only run once? I assume so but if not this is probably going to be a perf regression.

Yes, static makes it only get run once.
Comment 7 WebKit Commit Bot 2020-08-09 21:47:44 PDT
Re-opened since this is blocked by bug 215316
Comment 8 Alex Christensen 2020-08-10 09:03:19 PDT
CFBundleGetIdentifier returns null in jsc, and probably some other non-bundle tools.  I need to null check its return value, because passing null to CFEqual causes a crash.  Will fix.
Comment 9 Alex Christensen 2020-08-10 09:29:00 PDT
Created attachment 406300 [details]
Patch
Comment 10 Alex Christensen 2020-08-10 09:32:00 PDT
http://trac.webkit.org/r265431
Comment 11 Simon Fraser (smfr) 2020-08-10 10:01:56 PDT
Comment on attachment 406300 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406300&action=review

> Source/JavaScriptCore/runtime/JSObject.cpp:517
> +inline static bool isPokerBros()

This name is a lie, because the function also checks the linked-on-or-after version. A better function name would be needsPokerBrosQuirk().
Comment 12 Darin Adler 2020-08-10 10:49:12 PDT
Comment on attachment 406300 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406300&action=review

>> Source/JavaScriptCore/runtime/JSObject.cpp:517
>> +inline static bool isPokerBros()
> 
> This name is a lie, because the function also checks the linked-on-or-after version. A better function name would be needsPokerBrosQuirk().

We should not write "inline" here. It’s not valuable to inline the one-time code into JSObject::toStringName, and in fact might be counterproductive.
Comment 13 Darin Adler 2020-08-10 10:51:05 PDT
Comment on attachment 406300 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406300&action=review

> Source/JavaScriptCore/ChangeLog:10
> +        The PokerBros app has some logic that was broken by the change in behavior of r261159.
> +        It caused the app do do nothing except show a black screen upon opening.
> +        Revert to the old behavior for this app until they update to iOS14.

Normally we keep the quirks all in one place to help us remember to remove them over time. I worry that this one won’t be remembered.
Comment 14 Alex Christensen 2020-08-10 11:38:30 PDT
"inline" is just a suggestion, and might not even change the output of the compiler.  __attribute__((always_inline)) forces the compiler to inline.  I will remove the "inline" keyword, but I don't think that is necessary before this is copied to the branch.

I'll also rename the function to needsPokerBrosQuirk later.

We keep the quirks in the same place in WebCore, but this quirk is needed in JSC because it is in use of the JSC API in the app, not in web content.  The JSC team keeps track of these quirks and removes them when they can.
Comment 15 Darin Adler 2020-08-10 11:41:13 PDT
(In reply to Alex Christensen from comment #14)
> "inline" is just a suggestion

Yes, fully aware of that. Just not necessarily a good suggestion in this case.

> I don't think that is necessary before
> this is copied to the branch.

I agree.

> We keep the quirks in the same place in WebCore, but this quirk is needed in
> JSC because it is in use of the JSC API in the app, not in web content.  The
> JSC team keeps track of these quirks and removes them when they can.

How do we keep track of them? Where are the others?

I could imagine putting them all in one source file to keep track of them.
Comment 16 Alex Christensen 2020-08-10 11:44:31 PDT
(In reply to Darin Adler from comment #15)
> How do we keep track of them? Where are the others?
> 
> I could imagine putting them all in one source file to keep track of them.

They are all in one source file because there is only one right now.  Another one was removed in r234894