Closed Bug 921157 Opened 11 years ago Closed 4 years ago

Deprecate FileUtils.getDir(..., ..., true) during startup/shutdown

Categories

(Toolkit :: General, defect)

defect
Not set
major

Tracking

()

RESOLVED FIXED
mozilla80
Tracking Status
firefox80 --- fixed

People

(Reporter: Yoric, Assigned: kenrick95, Mentored)

References

Details

(Whiteboard: [Async:ready][lang=js])

Attachments

(1 file)

FileUtils.getDir(..., ..., true) causes main thread I/O. That's pretty bad, especially during startup/shutdown. We should alter FileUtils.jsm to print out warnings when we use this method during startup/shutdown.
Hi Yoric, I would like to work on this bug. Could please help me get started with it? Thanks.
To add a deprecation warning, you will need to patch this file: http://dxr.mozilla.org/mozilla-central/source/toolkit/modules/FileUtils.jsm?from=FileUtils.jsm#l62 to call into Deprecated.warning (module Deprecated.jsm ) whenever we call FileUtils.getDir(). Now, the more complicated part is to make this happen only during startup/shutdown. For this, you will need to implement a xpcom component in JavaScript, to determine the current stage of execution you're in: - before sessionstore-windows-restored (in this case, the call is deprecated); - after sessionstore-window-restored and before quit-application-granted (in this case, the call is ok); - after quit-application-granted (in this case, the call is deprecated again). Take a look at https://developer.mozilla.org/en-US/docs/Observer_Notifications and https://developer.mozilla.org/en-US/docs/XPCOM/Receiving_startup_notifications for more details.
Actually, let's not handle the second part of the bug yet – bug 881667 will make it much simpler.
Are you still working on this, Abhishek?
Flags: needinfo?(abhishekp.bugzilla)
No Yoric, Sorry, I won't be able to work on this.
Flags: needinfo?(abhishekp.bugzilla)
Severity: normal → major
Whiteboard: [Async][mentor=Yoric][lang=js] → [Async:ready][mentor=Yoric][lang=js]
I would like to take this. Could you please give me more guide? Thank you.
Have you already looked at comment 2?
Let's keep this bug for when we have made OS.File startup fast enough.
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → WONTFIX
Let's keep this open (sometimes FileUtils.getDir(..., ..., true) is used even if it is unnecessary, so we don't always need OS.File).
Status: RESOLVED → REOPENED
Resolution: WONTFIX → ---
Mentor: dteller
Whiteboard: [Async:ready][mentor=Yoric][lang=js] → [Async:ready][lang=js]

Hi, this looks interesting and would like to try it out.

May I confirm if now the required things to do is to only add Deprecate.warning call in FileUtils.getDir when the 3rd parameter (shouldCreate) is passed as true? Do I need to handle calling Deprecate.warning only during startup/shutdown? If so, since bug 881667 has been closed, what's the recommended way to know whether it is called during startup/shutdown?

Thanks :)

Flags: needinfo?(dteller)

That's great :)

May I confirm if now the required things to do is to only add Deprecate.warning call in FileUtils.getDir when the 3rd parameter (shouldCreate) is passed as true?

Exactly.

Do I need to handle calling Deprecate.warning only during startup/shutdown?

Indeed.

If so, since bug 881667 has been closed, what's the recommended way to know whether it is called during startup/shutdown?

Well, it has been closed because it has been fixed :)

These days, the simplest way to know whether we're during startup is to call nsIAppStartup.

Something like

let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);

if (appStartup.startingUp) {
  // We're starting up.
}

if (appStartup.shuttingDown) {
  // We're shutting down.
}
Flags: needinfo?(dteller) → needinfo?(kenrick95)

Got it!

I think I would be able to send a patch soon. But to make sure, how do you suggest to test this behavior?

Thanks

Flags: needinfo?(kenrick95) → needinfo?(dteller)

Because passing true to the 3rd parameter (shouldCreate)
causes main thread I/O and should be avoided
especially during startup/shutdown

Assignee: nobody → kenrick95

Unfortunately, I don't see any good way to test this. Let's first test that it doesn't break anything :)

Flags: needinfo?(dteller)

Florian, do you have any idea on how we could test this?

Flags: needinfo?(florian)

Do you want a test to verify that the deprecation warning has been emitted, or a test to ensure this is not being used during startup/shutdown?

I think you could have Deprecated.jsm add profiler markers that should be possible to access during startup tests.

Flags: needinfo?(florian)

Do you want a test to verify that the deprecation warning has been emitted, or a test to ensure this is not being used during startup/shutdown?

The former for the time being.

I think you could have Deprecated.jsm add profiler markers that should be possible to access during startup tests.

Could you mentor kenrick95 on this?

Flags: needinfo?(florian)

It seems to work, so let's land it.

Pushed by dteller@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/cf1b45188567 Deprecate FileUtils.getDir(..., ..., true) during startup/shutdown
Status: REOPENED → RESOLVED
Closed: 11 years ago4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla80
Regressions: 1651271
See Also: → 1651318
Blocks: 1651628
Flags: needinfo?(florian)

Should this bug get flagged with the "Perf" key word?

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: