Bug 201290 - Web Inspector: Import file pickers sometimes do not import
Summary: Web Inspector: Import file pickers sometimes do not import
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Joseph Pecoraro
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-08-29 00:03 PDT by Joseph Pecoraro
Modified: 2019-08-29 23:59 PDT (History)
6 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (4.23 KB, patch)
2019-08-29 00:05 PDT, Joseph Pecoraro
hi: review+
Details | Formatted Diff | Diff
[PATCH] For Landing (4.47 KB, patch)
2019-08-29 00:29 PDT, Joseph Pecoraro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2019-08-29 00:03:20 PDT
Import file pickers sometimes do not import

Steps to Reproduce:
1. Inspect webkit.org
2. Show Timeline tab
3. Click "Import" button
4. Select a previously exported recording
  => Nothing happens

Notes:
• FileChooser::invalidate happened because the input element got GC'd => "change" handler never fired

Lets keep the <input type="file"> around artificially.
Comment 1 Radar WebKit Bug Importer 2019-08-29 00:03:34 PDT
<rdar://problem/54826117>
Comment 2 Joseph Pecoraro 2019-08-29 00:05:25 PDT
Created attachment 377549 [details]
[PATCH] Proposed Fix
Comment 3 Devin Rousso 2019-08-29 00:14:10 PDT
Comment on attachment 377549 [details]
[PATCH] Proposed Fix

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

r=me, nice catch!  Really odd that an active input can get GC'd 🤔

> Source/WebInspectorUI/UserInterface/Base/FileUtilities.js:91
> +        fileReader.readAsDataURL(saveData.content);

Nice!

> Source/WebInspectorUI/UserInterface/Base/FileUtilities.js:96
> +        if (!FileUtilities.importTextInputElement) {

Could we use an "_" prefixed value to make sure callers know it's private?  Just like `WI.ImageUtilities._scratchContext2D`.

> Source/WebInspectorUI/UserInterface/Base/FileUtilities.js:111
> +        if (!FileUtilities.importJSONInputElement) {

Do we need a separate <input> for text vs json?  Theoretically, only one can be active at a time, so it shouldn't be an issue.

> Source/WebInspectorUI/UserInterface/Base/FileUtilities.js:135
>              let reader = new FileReader;

You could also move this inside the `Promise` as well, as it's not needed anywhere outside.
Comment 4 Joseph Pecoraro 2019-08-29 00:20:49 PDT
> > Source/WebInspectorUI/UserInterface/Base/FileUtilities.js:96
> > +        if (!FileUtilities.importTextInputElement) {
> 
> Could we use an "_" prefixed value to make sure callers know it's private? 
> Just like `WI.ImageUtilities._scratchContext2D`.

Sure.

> > Source/WebInspectorUI/UserInterface/Base/FileUtilities.js:111
> > +        if (!FileUtilities.importJSONInputElement) {
> 
> Do we need a separate <input> for text vs json?  Theoretically, only one can
> be active at a time, so it shouldn't be an issue.

Let's keep it separate. If the other bug gets addressed we can just revert this code!


> 
> > Source/WebInspectorUI/UserInterface/Base/FileUtilities.js:135
> >              let reader = new FileReader;
> 
> You could also move this inside the `Promise` as well, as it's not needed
> anywhere outside.

Might as well!
Comment 5 Joseph Pecoraro 2019-08-29 00:29:50 PDT
Created attachment 377554 [details]
[PATCH] For Landing
Comment 6 WebKit Commit Bot 2019-08-29 01:23:44 PDT
The commit-queue encountered the following flaky tests while processing attachment 377554 [details]:

svg/custom/tabindex-order.html bug 201294 (authors: krit@webkit.org and rniwa@webkit.org)
The commit-queue is continuing to process your patch.
Comment 7 WebKit Commit Bot 2019-08-29 01:24:24 PDT
Comment on attachment 377554 [details]
[PATCH] For Landing

Clearing flags on attachment: 377554

Committed r249248: <https://trac.webkit.org/changeset/249248>