Skip to content

Commit 9d653e5

Browse files
authored
dart2wasm experiment is opted in by default (#9530)
1 parent 535585d commit 9d653e5

5 files changed

Lines changed: 29 additions & 83 deletions

File tree

packages/devtools_app/lib/src/framework/scaffold/settings_dialog.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class SettingsDialog extends StatelessWidget {
8282
...dialogSubHeader(theme, 'Experimental features'),
8383
Flexible(
8484
child: CheckboxSetting(
85-
title: 'Enable WebAssembly',
85+
title: '[Recommended] Enable WebAssembly',
8686
description:
8787
'This will trigger a reload of the page to load DevTools '
8888
'compiled with WebAssembly. This may yield better '

packages/devtools_app/lib/src/shared/managers/banner_messages.dart

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -545,39 +545,6 @@ class WelcomeToNewInspectorMessage extends BannerInfo {
545545
);
546546
}
547547

548-
class WasmWelcomeMessage extends BannerInfo {
549-
WasmWelcomeMessage()
550-
: super(
551-
key: const Key('WasmWelcomeMessage'),
552-
screenId: universalScreenId,
553-
dismissOnConnectionChanges: true,
554-
buildTextSpans: (context) => [
555-
const TextSpan(
556-
text:
557-
'🚀 A faster and more performant DevTools is now available on WebAssembly! Click ',
558-
),
559-
const TextSpan(
560-
text: 'Enable',
561-
style: TextStyle(fontWeight: FontWeight.bold),
562-
),
563-
const TextSpan(text: ' to try it out now.'),
564-
const TextSpan(
565-
text: ' Please note that this will trigger a reload of DevTools.',
566-
style: TextStyle(fontStyle: FontStyle.italic),
567-
),
568-
],
569-
buildActions: (context) => [
570-
DevToolsButton(
571-
label: 'Enable',
572-
onPressed: () async {
573-
await preferences.enableWasmInStorage();
574-
webReload();
575-
},
576-
),
577-
],
578-
);
579-
}
580-
581548
void maybePushDebugModePerformanceMessage(String screenId) {
582549
if (offlineDataController.showingOfflineData.value) return;
583550
if (serviceConnection.serviceManager.connectedApp?.isDebugFlutterAppNow ??
@@ -610,10 +577,6 @@ void pushWelcomeToNewInspectorMessage(String screenId) {
610577
bannerMessages.addMessage(WelcomeToNewInspectorMessage(screenId: screenId));
611578
}
612579

613-
void pushWasmWelcomeMessage() {
614-
bannerMessages.addMessage(WasmWelcomeMessage());
615-
}
616-
617580
extension BannerMessageThemeExtension on ThemeData {
618581
TextStyle get warningMessageLinkStyle => regularTextStyle.copyWith(
619582
decoration: TextDecoration.underline,

packages/devtools_app/lib/src/shared/preferences/preferences.dart

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import '../constants.dart';
1919
import '../diagnostics/inspector_service.dart';
2020
import '../feature_flags.dart';
2121
import '../globals.dart';
22-
import '../managers/banner_messages.dart';
2322
import '../primitives/query_parameters.dart';
2423
import '../server/server.dart';
2524
import '../utils/utils.dart';
@@ -38,7 +37,11 @@ const _thirdPartyPathSegment = 'third_party';
3837

3938
/// DevTools preferences for experimental features.
4039
enum _ExperimentPreferences {
41-
wasm;
40+
/// Deprecated, we ignore this key in favor of [wasmOptOut].
41+
wasm,
42+
43+
/// Whether a user has opted out of the dart2wasm experiment.
44+
wasmOptOut;
4245

4346
String get storageKey => '$storagePrefix.$name';
4447

@@ -66,8 +69,6 @@ enum _GeneralPreferences { verboseLogging }
6669
/// A controller for global application preferences.
6770
class PreferencesController extends DisposableController
6871
with AutoDisposeControllerMixin {
69-
static const _welcomeShownStorageId = 'wasmWelcomeShown';
70-
7172
/// Whether the user preference for DevTools theme is set to dark mode.
7273
///
7374
/// To check whether DevTools is using a light or dark theme, other parts of
@@ -191,25 +192,13 @@ class PreferencesController extends DisposableController
191192
);
192193
}
193194

194-
// Maybe show the WASM welcome message on app connection if this is the
195-
// first time the user is loading DevTools after the WASM experiment was
196-
// enabled.
197-
addAutoDisposeListener(
198-
serviceConnection.serviceManager.connectedState,
199-
() async {
200-
if (serviceConnection.serviceManager.connectedState.value.connected) {
201-
await _maybeShowWasmWelcomeMessage();
202-
}
203-
},
204-
);
205-
206195
addAutoDisposeListener(wasmEnabled, () async {
207196
final enabled = wasmEnabled.value;
208197
_log.fine('preference update (wasmEnabled = $enabled)');
209198

210199
await storage.setValue(
211-
_ExperimentPreferences.wasm.storageKey,
212-
'$enabled',
200+
_ExperimentPreferences.wasmOptOut.storageKey,
201+
'${!enabled}',
213202
);
214203

215204
// Update the wasm mode query parameter if it does not match the value of
@@ -227,10 +216,12 @@ class PreferencesController extends DisposableController
227216
}
228217
});
229218

230-
final enabledFromStorage = await boolValueFromStorage(
231-
_ExperimentPreferences.wasm.storageKey,
219+
final optOutFromStorage = await boolValueFromStorage(
220+
_ExperimentPreferences.wasmOptOut.storageKey,
232221
defaultsTo: false,
233222
);
223+
final enabledFromStorage = !optOutFromStorage;
224+
234225
final queryParams = DevToolsQueryParams.load();
235226
final enabledFromQueryParams = queryParams.useWasm;
236227

@@ -269,23 +260,6 @@ class PreferencesController extends DisposableController
269260
toggleWasmEnabled(shouldEnableWasm);
270261
}
271262

272-
Future<void> _maybeShowWasmWelcomeMessage() async {
273-
// If we have already shown the welcome message, don't show it again.
274-
final welcomeAlreadyShown = await storage.getValue(_welcomeShownStorageId);
275-
if (welcomeAlreadyShown == 'true') return;
276-
277-
// Show the welcome message if the WASM experiment is enabled but the user
278-
// is not using the WASM build.
279-
final connectedApp = serviceConnection.serviceManager.connectedApp;
280-
if (connectedApp != null &&
281-
FeatureFlags.wasmByDefault.isEnabled(connectedApp) &&
282-
!kIsWasm) {
283-
// Mark the welcome message as shown.
284-
await storage.setValue(_welcomeShownStorageId, 'true');
285-
pushWasmWelcomeMessage();
286-
}
287-
}
288-
289263
Future<void> _initVerboseLogging() async {
290264
final verboseLoggingEnabledValue = await boolValueFromStorage(
291265
_GeneralPreferences.verboseLogging.name,

packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ To learn more about DevTools, check out the
1515

1616
## General updates
1717

18-
TODO: Remove this section if there are not any general updates.
18+
- Switched default compiler for DevTools to `dart2wasm`. - [#9530](https://github.com/flutter/devtools/pull/9530)
1919

2020
## Inspector updates
2121

packages/devtools_app/web/flutter_bootstrap.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ function getSearchParam(searchParamKey) {
3333
}
3434

3535
// Calls the DevTools server API to read the user's wasm preference.
36-
async function getDevToolsWasmPreference() {
36+
async function getDevToolsWasmOptOutPreference() {
3737
// Note: when the DevTools server is running on a different port than the
3838
// DevTools web app, this request path will be incorrect and the request
3939
// will fail. This is okay because DevTools cannot be built with WASM when
4040
// running from `flutter run` anyway.
41-
const request = 'api/getPreferenceValue?key=experiment.wasm';
41+
const request = 'api/getPreferenceValue?key=experiment.wasmOptOut';
4242
try {
4343
const response = await fetch(request);
4444
if (!response.ok) {
@@ -47,10 +47,10 @@ async function getDevToolsWasmPreference() {
4747
}
4848

4949
// The response text should be an encoded boolean value ("true" or "false").
50-
const wasmEnabled = JSON.parse(await response.text());
51-
return wasmEnabled === true || wasmEnabled === 'true';
50+
const isOptedOut = JSON.parse(await response.text());
51+
return isOptedOut === true || isOptedOut === 'true';
5252
} catch (error) {
53-
console.error('Error fetching experiment.wasm preference value:', error);
53+
console.error('Error fetching experiment.wasmOptOut preference value:', error);
5454
return false;
5555
}
5656
}
@@ -68,9 +68,18 @@ async function shouldUseSkwasm() {
6868
if (forceUseJs()) {
6969
return false;
7070
}
71+
7172
const wasmEnabledFromQueryParameter = getSearchParam(compilerQueryParameterKey) === 'wasm';
72-
const wasmEnabledFromDevToolsPreference = await getDevToolsWasmPreference();
73-
return wasmEnabledFromQueryParameter === true || wasmEnabledFromDevToolsPreference === true;
73+
if (wasmEnabledFromQueryParameter) {
74+
return true;
75+
}
76+
77+
const userHasOptedOut = await getDevToolsWasmOptOutPreference();
78+
if (userHasOptedOut) {
79+
return false;
80+
}
81+
82+
return true;
7483
}
7584

7685
// Sets or removes the 'wasm' query parameter based on whether DevTools should

0 commit comments

Comments
 (0)