Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
f2417e6c
Unverified
Commit
f2417e6c
authored
Apr 21, 2021
by
Jenn Magder
Committed by
GitHub
Apr 21, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Launch Chrome natively on ARM macOS (#80758)
parent
b5d521f9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
130 additions
and
2 deletions
+130
-2
chrome.dart
packages/flutter_tools/lib/src/web/chrome.dart
+13
-2
chrome_test.dart
...ges/flutter_tools/test/general.shard/web/chrome_test.dart
+115
-0
context.dart
packages/flutter_tools/test/src/context.dart
+2
-0
No files found.
packages/flutter_tools/lib/src/web/chrome.dart
View file @
f2417e6c
...
...
@@ -218,7 +218,7 @@ class ChromiumLauncher {
url
,
];
final
Process
?
process
=
await
_spawnChromiumProcess
(
args
);
final
Process
?
process
=
await
_spawnChromiumProcess
(
args
,
chromeExecutable
);
// When the process exits, copy the user settings back to the provided data-dir.
if
(
process
!=
null
&&
cacheDir
!=
null
)
{
...
...
@@ -235,7 +235,18 @@ class ChromiumLauncher {
),
skipCheck
);
}
Future
<
Process
?>
_spawnChromiumProcess
(
List
<
String
>
args
)
async
{
Future
<
Process
?>
_spawnChromiumProcess
(
List
<
String
>
args
,
String
chromeExecutable
)
async
{
if
(
_operatingSystemUtils
.
hostPlatform
==
HostPlatform
.
darwin_arm
)
{
final
ProcessResult
result
=
_processManager
.
runSync
(<
String
>[
'file'
,
chromeExecutable
]);
// Check if ARM Chrome is installed.
// Mach-O 64-bit executable arm64
if
((
result
.
stdout
as
String
).
contains
(
'arm64'
))
{
_logger
.
printTrace
(
'Found ARM Chrome installation at
$chromeExecutable
, forcing native launch.'
);
// If so, force Chrome to launch natively.
args
.
insertAll
(
0
,
<
String
>[
'/usr/bin/arch'
,
'-arm64'
]);
}
}
// Keep attempting to launch the browser until one of:
// - Chrome launched successfully, in which case we just return from the loop.
// - The tool detected an unretriable Chrome error, in which case we throw ToolExit.
...
...
packages/flutter_tools/test/general.shard/web/chrome_test.dart
View file @
f2417e6c
...
...
@@ -189,6 +189,121 @@ void main() {
expect
(
logger
.
errorText
,
contains
(
'Failed to restore Chrome preferences'
));
});
testWithoutContext
(
'can launch Chrome on x86_64 macOS'
,
()
async
{
final
OperatingSystemUtils
macOSUtils
=
FakeOperatingSystemUtils
(
hostPlatform:
HostPlatform
.
darwin_x64
);
final
ChromiumLauncher
chromiumLauncher
=
ChromiumLauncher
(
fileSystem:
fileSystem
,
platform:
platform
,
processManager:
processManager
,
operatingSystemUtils:
macOSUtils
,
browserFinder:
findChromeExecutable
,
logger:
BufferLogger
.
test
(),
);
processManager
.
addCommands
(<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'example_chrome'
,
'--user-data-dir=/.tmp_rand0/flutter_tools_chrome_device.rand0'
,
'--remote-debugging-port=12345'
,
...
kChromeArgs
,
'example_url'
,
],
stderr:
kDevtoolsStderr
,
)
]);
expect
(
()
async
=>
chromiumLauncher
.
launch
(
'example_url'
,
skipCheck:
true
,
),
returnsNormally
,
);
});
testWithoutContext
(
'can launch x86_64 Chrome on ARM macOS'
,
()
async
{
final
OperatingSystemUtils
macOSUtils
=
FakeOperatingSystemUtils
(
hostPlatform:
HostPlatform
.
darwin_arm
);
final
ChromiumLauncher
chromiumLauncher
=
ChromiumLauncher
(
fileSystem:
fileSystem
,
platform:
platform
,
processManager:
processManager
,
operatingSystemUtils:
macOSUtils
,
browserFinder:
findChromeExecutable
,
logger:
BufferLogger
.
test
(),
);
processManager
.
addCommands
(<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'file'
,
'example_chrome'
,
],
stdout:
'Mach-O 64-bit executable x86_64'
,
),
const
FakeCommand
(
command:
<
String
>[
'example_chrome'
,
'--user-data-dir=/.tmp_rand0/flutter_tools_chrome_device.rand0'
,
'--remote-debugging-port=12345'
,
...
kChromeArgs
,
'example_url'
,
],
stderr:
kDevtoolsStderr
,
)
]);
expect
(
()
async
=>
chromiumLauncher
.
launch
(
'example_url'
,
skipCheck:
true
,
),
returnsNormally
,
);
});
testWithoutContext
(
'can launch ARM Chrome natively on ARM macOS when installed'
,
()
async
{
final
OperatingSystemUtils
macOSUtils
=
FakeOperatingSystemUtils
(
hostPlatform:
HostPlatform
.
darwin_arm
);
final
ChromiumLauncher
chromiumLauncher
=
ChromiumLauncher
(
fileSystem:
fileSystem
,
platform:
platform
,
processManager:
processManager
,
operatingSystemUtils:
macOSUtils
,
browserFinder:
findChromeExecutable
,
logger:
BufferLogger
.
test
(),
);
processManager
.
addCommands
(<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'file'
,
'example_chrome'
,
],
stdout:
'Mach-O 64-bit executable arm64'
,
),
const
FakeCommand
(
command:
<
String
>[
'/usr/bin/arch'
,
'-arm64'
,
'example_chrome'
,
'--user-data-dir=/.tmp_rand0/flutter_tools_chrome_device.rand0'
,
'--remote-debugging-port=12345'
,
...
kChromeArgs
,
'example_url'
,
],
stderr:
kDevtoolsStderr
,
),
]);
expect
(
()
async
=>
chromiumLauncher
.
launch
(
'example_url'
,
skipCheck:
true
,
),
returnsNormally
,
);
});
testWithoutContext
(
'can launch chrome with a custom debug port'
,
()
async
{
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
...
...
packages/flutter_tools/test/src/context.dart
View file @
f2417e6c
...
...
@@ -296,6 +296,8 @@ class MockSimControl extends Mock implements SimControl {
}
class
FakeOperatingSystemUtils
implements
OperatingSystemUtils
{
FakeOperatingSystemUtils
({
this
.
hostPlatform
=
HostPlatform
.
linux_x64
});
@override
ProcessResult
makeExecutable
(
File
file
)
=>
null
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment