WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
159410
When WKWebView prepares the session state blob, we should be able to filter it.
https://bugs.webkit.org/show_bug.cgi?id=159410
Summary
When WKWebView prepares the session state blob, we should be able to filter it.
Yongjun Zhang
Reported
2016-07-04 21:31:29 PDT
It would be nice to add a SPI to WKBackForwardList so that a WebKit client can remove the current item.
Attachments
Patch.
(12.52 KB, patch)
2016-07-04 21:48 PDT
,
Yongjun Zhang
no flags
Details
Formatted Diff
Diff
Fix style issue.
(12.48 KB, patch)
2016-07-04 22:03 PDT
,
Yongjun Zhang
beidson
: review-
Details
Formatted Diff
Diff
Add a SPI to WKWebView so that we can filter the session state.
(3.18 KB, patch)
2016-07-06 11:35 PDT
,
Yongjun Zhang
no flags
Details
Formatted Diff
Diff
Address review comments.
(2.98 KB, patch)
2016-07-06 14:40 PDT
,
Yongjun Zhang
no flags
Details
Formatted Diff
Diff
Fix build issues.
(2.98 KB, patch)
2016-07-07 10:44 PDT
,
Yongjun Zhang
no flags
Details
Formatted Diff
Diff
Show Obsolete
(4)
View All
Add attachment
proposed patch, testcase, etc.
Yongjun Zhang
Comment 1
2016-07-04 21:32:23 PDT
rdar://problem/26565813
Yongjun Zhang
Comment 2
2016-07-04 21:48:44 PDT
Created
attachment 282746
[details]
Patch.
WebKit Commit Bot
Comment 3
2016-07-04 21:51:14 PDT
Attachment 282746
[details]
did not pass style-queue: ERROR: Source/WebKit2/ChangeLog:16: Line contains tab character. [whitespace/tab] [5] ERROR: Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKBackForwardList.mm:29: Alphabetical sorting problem. [build/include_order] [4] ERROR: Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKBackForwardList.mm:33: Bad include order. Mixing system and custom headers. [build/include_order] [4] Total errors found: 3 in 8 files If any of these errors are false positives, please file a bug against check-webkit-style.
Yongjun Zhang
Comment 4
2016-07-04 22:03:25 PDT
Created
attachment 282747
[details]
Fix style issue.
Brady Eidson
Comment 5
2016-07-05 08:46:03 PDT
Comment on
attachment 282747
[details]
Fix style issue. We've resisted APIs to directly manipulate the back/forward list for the entirety of WK2. Every time we've heard that one is needed, we've always found an alternate. Why is this needed?
Yongjun Zhang
Comment 6
2016-07-05 10:00:43 PDT
(In reply to
comment #5
)
> Comment on
attachment 282747
[details]
> Fix style issue. > > We've resisted APIs to directly manipulate the back/forward list for the > entirety of WK2. > > Every time we've heard that one is needed, we've always found an alternate. > > Why is this needed?
Sometimes when we restore the saved session state from disk, we would like to skip the current item (to prevent crash-loop if the app crashed because of loading the URL in current item). We can't just do bfList->back since that would make it possible to go forward and crash again if user swipes forward. Seems like there isn't a good way to achieve this with the current API/SPI. Any suggestions?
Brady Eidson
Comment 7
2016-07-05 10:05:03 PDT
(In reply to
comment #6
)
> (In reply to
comment #5
) > > Comment on
attachment 282747
[details]
> > Fix style issue. > > > > We've resisted APIs to directly manipulate the back/forward list for the > > entirety of WK2. > > > > Every time we've heard that one is needed, we've always found an alternate. > > > > Why is this needed? > > Sometimes when we restore the saved session state from disk, we would like > to skip the current item (to prevent crash-loop if the app crashed because > of loading the URL in current item). We can't just do bfList->back since > that would make it possible to go forward and crash again if user swipes > forward. > > Seems like there isn't a good way to achieve this with the current API/SPI. > Any suggestions?
-Take the session state blob -Restore without navigating -Make a new session state blob, but filter out the bad url. -Restore the new session state blob
Yongjun Zhang
Comment 8
2016-07-05 20:14:43 PDT
(In reply to
comment #7
)
> (In reply to
comment #6
) > > (In reply to
comment #5
) > > > Comment on
attachment 282747
[details]
> > > Fix style issue. > > > > > > We've resisted APIs to directly manipulate the back/forward list for the > > > entirety of WK2. > > > > > > Every time we've heard that one is needed, we've always found an alternate. > > > > > > Why is this needed? > > > > Sometimes when we restore the saved session state from disk, we would like > > to skip the current item (to prevent crash-loop if the app crashed because > > of loading the URL in current item). We can't just do bfList->back since > > that would make it possible to go forward and crash again if user swipes > > forward. > > > > Seems like there isn't a good way to achieve this with the current API/SPI. > > Any suggestions? > > -Take the session state blob > -Restore without navigating > -Make a new session state blob, but filter out the bad url. > -Restore the new session state blob
Thanks Brady! I will try this approach.
Yongjun Zhang
Comment 9
2016-07-06 11:35:14 PDT
Created
attachment 282914
[details]
Add a SPI to WKWebView so that we can filter the session state.
Brady Eidson
Comment 10
2016-07-06 14:03:54 PDT
Comment on
attachment 282914
[details]
Add a SPI to WKWebView so that we can filter the session state. View in context:
https://bugs.webkit.org/attachment.cgi?id=282914&action=review
> Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:3378 > + auto handler = adoptNS([filter copy]); > + WebKit::SessionState sessionState = _page->sessionState([handler](WebKit::WebBackForwardListItem& item) {
Can put the filter copy inside the lambda: [handler = adoptNS([filter copy])]
> Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:3384 > + BOOL (^filterBlock)(WKBackForwardListItem *item) = (BOOL (^)(WKBackForwardListItem *item))handler.get(); > + if (filterBlock) { > + if (!filterBlock(wrapper(item))) > + return false; > + } > + return true;
This should be able to be simpler: if (!handler) return true; BOOL (^filterBlock)(WKBackForwardListItem *item) = (BOOL (^)(WKBackForwardListItem *item))handler.get(); return filterBlock(wrapper(item));
Anders Carlsson
Comment 11
2016-07-06 14:06:55 PDT
Comment on
attachment 282914
[details]
Add a SPI to WKWebView so that we can filter the session state. View in context:
https://bugs.webkit.org/attachment.cgi?id=282914&action=review
>> Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:3378 >> + WebKit::SessionState sessionState = _page->sessionState([handler](WebKit::WebBackForwardListItem& item) { > > Can put the filter copy inside the lambda: > [handler = adoptNS([filter copy])]
I don't think the block needs to be copied at all? If it does, just use WTF::BlockPtr instead.
Yongjun Zhang
Comment 12
2016-07-06 14:35:51 PDT
(In reply to
comment #11
)
> Comment on
attachment 282914
[details]
> Add a SPI to WKWebView so that we can filter the session state. > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=282914&action=review
> > >> Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:3378 > >> + WebKit::SessionState sessionState = _page->sessionState([handler](WebKit::WebBackForwardListItem& item) { > > > > Can put the filter copy inside the lambda: > > [handler = adoptNS([filter copy])] > > I don't think the block needs to be copied at all? If it does, just use > WTF::BlockPtr instead.
Right, we don't need copy here since WebPageProxy::sessionState is a synchronous call.
Yongjun Zhang
Comment 13
2016-07-06 14:40:51 PDT
Created
attachment 282950
[details]
Address review comments.
Yongjun Zhang
Comment 14
2016-07-07 10:44:56 PDT
Created
attachment 283023
[details]
Fix build issues.
Brady Eidson
Comment 15
2016-07-08 17:09:14 PDT
Comment on
attachment 283023
[details]
Fix build issues. View in context:
https://bugs.webkit.org/attachment.cgi?id=283023&action=review
> Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:3377 > + WebKit::SessionState sessionState = _page->sessionState([filter](WebKit::WebBackForwardListItem& item) {
[filter = WTFMove(filter)] will avoid a copy. It might just be a pointer copy as I'm not exactly sure how blocks are represented... but probably couldn't hurt!
WebKit Commit Bot
Comment 16
2016-07-08 17:43:56 PDT
Comment on
attachment 283023
[details]
Fix build issues. Clearing flags on attachment: 283023 Committed
r203014
: <
http://trac.webkit.org/changeset/203014
>
WebKit Commit Bot
Comment 17
2016-07-08 17:43:59 PDT
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug