Bug 196659 - [Cocoa] Awaken UIProcess if WebContent process is awakened from suspensions unexpectedly.
Summary: [Cocoa] Awaken UIProcess if WebContent process is awakened from suspensions u...
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: Jer Noble
URL:
Keywords: InRadar
Depends on:
Blocks: 210710
  Show dependency treegraph
 
Reported: 2019-04-05 15:17 PDT by Jer Noble
Modified: 2020-04-18 19:26 PDT (History)
6 users (show)

See Also:


Attachments
WIP (29.97 KB, patch)
2019-04-05 15:20 PDT, Jer Noble
no flags Details | Formatted Diff | Diff
Patch for landing (30.69 KB, patch)
2019-04-08 11:59 PDT, Jer Noble
no flags Details | Formatted Diff | Diff
Patch for landing (30.74 KB, patch)
2019-04-08 12:02 PDT, Jer Noble
no flags Details | Formatted Diff | Diff
Patch for landing (30.97 KB, patch)
2019-04-08 13:01 PDT, Jer Noble
no flags Details | Formatted Diff | Diff
Patch for landing (31.10 KB, patch)
2019-04-09 09:03 PDT, Jer Noble
no flags Details | Formatted Diff | Diff
Patch for landing (31.11 KB, patch)
2019-04-09 09:31 PDT, Jer Noble
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jer Noble 2019-04-05 15:17:14 PDT
[Cocoa] Awaken UIProcess in WebContent process is awakened from suspensions unexpectedly.
Comment 1 Jer Noble 2019-04-05 15:20:27 PDT
Created attachment 366849 [details]
WIP
Comment 2 Chris Dumez 2019-04-05 15:40:20 PDT
Comment on attachment 366849 [details]
WIP

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

> Source/WebKit/Shared/Cocoa/ProcessTaskStateObserver.h:40
> +    ProcessTaskStateObserver(Client&);

explicit?

> Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm:44
> +static const Seconds UnexpectedActivityDuration = 10_s;

I think our statics usually start with a lowercase letter.

> Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:306
> +        uiProcessAssertion->setState(AssertionState::Suspended);

Do we really need to do this? Why doesn't destroying the ProcessAssertion suffice?
Comment 3 Jer Noble 2019-04-05 15:48:07 PDT
(In reply to Chris Dumez from comment #2)
> Comment on attachment 366849 [details]
> WIP
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=366849&action=review
> 
> > Source/WebKit/Shared/Cocoa/ProcessTaskStateObserver.h:40
> > +    ProcessTaskStateObserver(Client&);
> 
> explicit?

Sure.

> > Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm:44
> > +static const Seconds UnexpectedActivityDuration = 10_s;
> 
> I think our statics usually start with a lowercase letter.

Ok.

> > Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:306
> > +        uiProcessAssertion->setState(AssertionState::Suspended);
> 
> Do we really need to do this? Why doesn't destroying the ProcessAssertion
> suffice?

It probably does suffice; I was taking a belt-and-suspenders approach. I'll remove this.
Comment 4 Geoffrey Garen 2019-04-05 15:51:05 PDT
Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -L/Volumes/Data/EWS/WebKit/WebKitBuild/Release -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/Frameworks -F/Volumes/Data/EWS/WebKit/WebKitBuild/Release -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/PrivateFrameworks -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks -filelist /Volumes/Data/EWS/WebKit/WebKitBuild/WebKit.build/Release/WebKit.build/Objects-normal/x86_64/WebKit.LinkFileList -Xlinker -reexport_framework -Xlinker WebKitLegacy -Xlinker -reexport_framework -Xlinker WebCore -install_name /System/Library/Frameworks/WebKit.framework/Versions/A/WebKit -mmacosx-version-min=10.13 -dead_strip -Xlinker -object_path_lto -Xlinker /Volumes/Data/EWS/WebKit/WebKitBuild/WebKit.build/Release/WebKit.build/Objects-normal/x86_64/WebKit_lto.o -stdlib=libc++ -fobjc-link-runtime -iframework/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/PrivateFrameworks -Wl,-unexported_symbol -Wl,__ZTISt9bad_alloc -Wl,-unexported_symbol -Wl,__ZTISt9exception -Wl,-unexported_symbol -Wl,__ZTSSt9bad_alloc -Wl,-unexported_symbol -Wl,__ZTSSt9exception -Wl,-unexported_symbol -Wl,__ZdlPvS_ -Wl,-unexported_symbol -Wl,__ZnwmPv -Wl,-unexported_symbol -Wl,__Znwm -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC2EOS4_ -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC1EOS4_ -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEaSEDn -Wl,-unexported_symbol -Wl,__ZNKSt3__18functionIFvN7WebCore12PolicyActionEEEclES2_ -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEE4swapERS4_ -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC1ERKS4_ -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEC2ERKS4_ -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEED1Ev -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEED2Ev -Wl,-unexported_symbol -Wl,__ZNSt3__18functionIFvN7WebCore12PolicyActionEEEaSERKS4_ -Wl,-unexported_symbol -Wl,__ZTVNSt3__117bad_function_callE -Wl,-unexported_symbol -Wl,__ZTCNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE0_NS_13basic_istreamIcS2_EE -Wl,-unexported_symbol -Wl,__ZTCNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE0_NS_14basic_iostreamIcS2_EE -Wl,-unexported_symbol -Wl,__ZTCNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE16_NS_13basic_ostreamIcS2_EE -Wl,-unexported_symbol -Wl,__ZTTNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE -Wl,-unexported_symbol -Wl,__ZTVNSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEEE -Wl,-unexported_symbol -Wl,__ZTVNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE -Wl,-unexported_symbol -Wl,__ZTCNSt3__118basic_stringstreamIcNS_11char_traitsIcEENS_9allocatorIcEEEE8_NS_13basic_ostreamIcS2_EE -lobjc -framework CFNetwork -framework CoreAudio -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework ImageIO -framework IOKit -framework WebKitLegacy -lnetwork -framework AppKit -framework Carbon -weak_framework CorePrediction -framework CoreServices -framework IOSurface -lsandbox -weak-lwebrtc -framework OpenGL -weak_framework SafariSafeBrowsing -framework SecurityInterface -weak_framework WebInspectorUI -Wl,-not_for_dyld_shared_cache -framework JavaScriptCore -licucore -framework QuartzCore -framework Security -framework WebCore -compatibility_version 1 -current_version 608.1.16 -Xlinker -dependency_info -Xlinker /Volumes/Data/EWS/WebKit/WebKitBuild/WebKit.build/Release/WebKit.build/Objects-normal/x86_64/WebKit_dependency_info.dat -o /Volumes/Data/EWS/WebKit/WebKitBuild/Release/WebKit.framework/Versions/A/WebKit
Undefined symbols for architecture x86_64:
  "WebKit::ProcessAssertion::ProcessAssertion(int, WTF::String const&, WebKit::AssertionState, WebKit::AssertionReason)", referenced from:
      WebKit::WebProcess::processTaskStateDidChange(WebKit::ProcessTaskStateObserver::TaskState) in UnifiedSource51-mm.o
  "_OBJC_CLASS_$_BKSProcess", referenced from:
      objc-class-ref in ProcessTaskStateObserver.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Comment 5 Darin Adler 2019-04-05 17:28:43 PDT
Comment on attachment 366849 [details]
WIP

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

> Source/WebKit/ChangeLog:3
> +        [Cocoa] Awaken UIProcess in WebContent process is awakened from suspensions unexpectedly.

Should be "if" instead of "in", right?
Comment 6 Jer Noble 2019-04-08 08:43:10 PDT
(In reply to Darin Adler from comment #5)
> Comment on attachment 366849 [details]
> WIP
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=366849&action=review
> 
> > Source/WebKit/ChangeLog:3
> > +        [Cocoa] Awaken UIProcess in WebContent process is awakened from suspensions unexpectedly.
> 
> Should be "if" instead of "in", right?

Yep!

(In reply to Geoffrey Garen from comment #4)
> Undefined symbols for architecture x86_64:
>   "WebKit::ProcessAssertion::ProcessAssertion(int, WTF::String const&,
> WebKit::AssertionState, WebKit::AssertionReason)", referenced from:
>      
> WebKit::WebProcess::processTaskStateDidChange(WebKit::
> ProcessTaskStateObserver::TaskState) in UnifiedSource51-mm.o

Yeah, I'll fix this; the non-iOS ProcessAssertion needs to have a constructor that takes a reason.

>   "_OBJC_CLASS_$_BKSProcess", referenced from:
>       objc-class-ref in ProcessTaskStateObserver.o

Ooh, looks like we need to soft-link the BKSProcess class.
Comment 7 Jer Noble 2019-04-08 10:42:07 PDT
> (In reply to Geoffrey Garen from comment #4)
> >   "_OBJC_CLASS_$_BKSProcess", referenced from:
> >       objc-class-ref in ProcessTaskStateObserver.o
> 
> Ooh, looks like we need to soft-link the BKSProcess class.

Aha, this is more prosaic: we don't link against AssertionServices.framework on macOS. While technically we could, maybe I'll just make this entire code-path iOS-only.
Comment 8 Jer Noble 2019-04-08 11:59:15 PDT
Created attachment 366959 [details]
Patch for landing
Comment 9 Jer Noble 2019-04-08 12:02:51 PDT
Created attachment 366961 [details]
Patch for landing
Comment 10 Jer Noble 2019-04-08 13:01:34 PDT
Created attachment 366969 [details]
Patch for landing
Comment 11 Jer Noble 2019-04-09 09:03:02 PDT
Created attachment 367040 [details]
Patch for landing
Comment 12 Jer Noble 2019-04-09 09:31:06 PDT
Created attachment 367042 [details]
Patch for landing
Comment 13 WebKit Commit Bot 2019-04-09 12:37:34 PDT
Comment on attachment 367042 [details]
Patch for landing

Clearing flags on attachment: 367042

Committed r244091: <https://trac.webkit.org/changeset/244091>
Comment 14 WebKit Commit Bot 2019-04-09 12:37:36 PDT
All reviewed patches have been landed.  Closing bug.
Comment 15 Radar WebKit Bug Importer 2019-04-09 12:38:53 PDT
<rdar://problem/49745738>