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
60033828
Unverified
Commit
60033828
authored
May 27, 2020
by
Jonah Williams
Committed by
GitHub
May 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] add vm service method to pull SkSL (#57813)
parent
f640ad69
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
69 additions
and
3 deletions
+69
-3
resident_runner.dart
packages/flutter_tools/lib/src/resident_runner.dart
+9
-2
run_cold.dart
packages/flutter_tools/lib/src/run_cold.dart
+3
-1
run_hot.dart
packages/flutter_tools/lib/src/run_hot.dart
+1
-0
vmservice.dart
packages/flutter_tools/lib/src/vmservice.dart
+24
-0
attach_test.dart
...utter_tools/test/commands.shard/hermetic/attach_test.dart
+1
-0
cold_test.dart
packages/flutter_tools/test/general.shard/cold_test.dart
+1
-0
hot_test.dart
packages/flutter_tools/test/general.shard/hot_test.dart
+1
-0
resident_runner_test.dart
...lutter_tools/test/general.shard/resident_runner_test.dart
+2
-0
vmservice_test.dart
...ages/flutter_tools/test/general.shard/vmservice_test.dart
+21
-0
vmservice_integration_test.dart
...ls/test/integration.shard/vmservice_integration_test.dart
+6
-0
No files found.
packages/flutter_tools/lib/src/resident_runner.dart
View file @
60033828
...
@@ -186,6 +186,7 @@ class FlutterDevice {
...
@@ -186,6 +186,7 @@ class FlutterDevice {
Restart
restart
,
Restart
restart
,
CompileExpression
compileExpression
,
CompileExpression
compileExpression
,
ReloadMethod
reloadMethod
,
ReloadMethod
reloadMethod
,
GetSkSLMethod
getSkSLMethod
,
})
{
})
{
final
Completer
<
void
>
completer
=
Completer
<
void
>();
final
Completer
<
void
>
completer
=
Completer
<
void
>();
StreamSubscription
<
void
>
subscription
;
StreamSubscription
<
void
>
subscription
;
...
@@ -204,6 +205,7 @@ class FlutterDevice {
...
@@ -204,6 +205,7 @@ class FlutterDevice {
restart:
restart
,
restart:
restart
,
compileExpression:
compileExpression
,
compileExpression:
compileExpression
,
reloadMethod:
reloadMethod
,
reloadMethod:
reloadMethod
,
getSkSLMethod:
getSkSLMethod
,
device:
device
,
device:
device
,
);
);
}
on
Exception
catch
(
exception
)
{
}
on
Exception
catch
(
exception
)
{
...
@@ -853,7 +855,9 @@ abstract class ResidentRunner {
...
@@ -853,7 +855,9 @@ abstract class ResidentRunner {
}
}
/// Write the SkSL shaders to a zip file in build directory.
/// Write the SkSL shaders to a zip file in build directory.
Future
<
void
>
writeSkSL
()
async
{
///
/// Returns the name of the file, or `null` on failures.
Future
<
String
>
writeSkSL
()
async
{
if
(!
supportsWriteSkSL
)
{
if
(!
supportsWriteSkSL
)
{
throw
Exception
(
'writeSkSL is not supported by this runner.'
);
throw
Exception
(
'writeSkSL is not supported by this runner.'
);
}
}
...
@@ -870,7 +874,7 @@ abstract class ResidentRunner {
...
@@ -870,7 +874,7 @@ abstract class ResidentRunner {
' 1. Pass "--cache-sksl" as an argument to flutter run.
\n
'
' 1. Pass "--cache-sksl" as an argument to flutter run.
\n
'
' 2. Interact with the application to force shaders to be compiled.
\n
'
' 2. Interact with the application to force shaders to be compiled.
\n
'
);
);
return
;
return
null
;
}
}
final
File
outputFile
=
globals
.
fsUtils
.
getUniqueFile
(
final
File
outputFile
=
globals
.
fsUtils
.
getUniqueFile
(
globals
.
fs
.
currentDirectory
,
globals
.
fs
.
currentDirectory
,
...
@@ -899,6 +903,7 @@ abstract class ResidentRunner {
...
@@ -899,6 +903,7 @@ abstract class ResidentRunner {
};
};
outputFile
.
writeAsStringSync
(
json
.
encode
(
manifest
));
outputFile
.
writeAsStringSync
(
json
.
encode
(
manifest
));
globals
.
logger
.
printStatus
(
'Wrote SkSL data to
${outputFile.path}
.'
);
globals
.
logger
.
printStatus
(
'Wrote SkSL data to
${outputFile.path}
.'
);
return
outputFile
.
path
;
}
}
/// The resident runner API for interaction with the reloadMethod vmservice
/// The resident runner API for interaction with the reloadMethod vmservice
...
@@ -1103,6 +1108,7 @@ abstract class ResidentRunner {
...
@@ -1103,6 +1108,7 @@ abstract class ResidentRunner {
Restart
restart
,
Restart
restart
,
CompileExpression
compileExpression
,
CompileExpression
compileExpression
,
ReloadMethod
reloadMethod
,
ReloadMethod
reloadMethod
,
GetSkSLMethod
getSkSLMethod
,
})
async
{
})
async
{
if
(!
debuggingOptions
.
debuggingEnabled
)
{
if
(!
debuggingOptions
.
debuggingEnabled
)
{
throw
'The service protocol is not enabled.'
;
throw
'The service protocol is not enabled.'
;
...
@@ -1115,6 +1121,7 @@ abstract class ResidentRunner {
...
@@ -1115,6 +1121,7 @@ abstract class ResidentRunner {
restart:
restart
,
restart:
restart
,
compileExpression:
compileExpression
,
compileExpression:
compileExpression
,
reloadMethod:
reloadMethod
,
reloadMethod:
reloadMethod
,
getSkSLMethod:
getSkSLMethod
);
);
// This will wait for at least one flutter view before returning.
// This will wait for at least one flutter view before returning.
final
Status
status
=
globals
.
logger
.
startProgress
(
final
Status
status
=
globals
.
logger
.
startProgress
(
...
...
packages/flutter_tools/lib/src/run_cold.dart
View file @
60033828
...
@@ -129,7 +129,9 @@ class ColdRunner extends ResidentRunner {
...
@@ -129,7 +129,9 @@ class ColdRunner extends ResidentRunner {
})
async
{
})
async
{
_didAttach
=
true
;
_didAttach
=
true
;
try
{
try
{
await
connectToServiceProtocol
();
await
connectToServiceProtocol
(
getSkSLMethod:
writeSkSL
,
);
}
on
Exception
catch
(
error
)
{
}
on
Exception
catch
(
error
)
{
globals
.
printError
(
'Error connecting to the service protocol:
$error
'
);
globals
.
printError
(
'Error connecting to the service protocol:
$error
'
);
// https://github.com/flutter/flutter/issues/33050
// https://github.com/flutter/flutter/issues/33050
...
...
packages/flutter_tools/lib/src/run_hot.dart
View file @
60033828
...
@@ -225,6 +225,7 @@ class HotRunner extends ResidentRunner {
...
@@ -225,6 +225,7 @@ class HotRunner extends ResidentRunner {
restart:
_restartService
,
restart:
_restartService
,
compileExpression:
_compileExpressionService
,
compileExpression:
_compileExpressionService
,
reloadMethod:
reloadMethod
,
reloadMethod:
reloadMethod
,
getSkSLMethod:
writeSkSL
,
);
);
// Catches all exceptions, non-Exception objects are rethrown.
// Catches all exceptions, non-Exception objects are rethrown.
}
catch
(
error
)
{
// ignore: avoid_catches_without_on_clauses
}
catch
(
error
)
{
// ignore: avoid_catches_without_on_clauses
...
...
packages/flutter_tools/lib/src/vmservice.dart
View file @
60033828
...
@@ -81,6 +81,12 @@ typedef ReloadMethod = Future<void> Function({
...
@@ -81,6 +81,12 @@ typedef ReloadMethod = Future<void> Function({
String
libraryId
,
String
libraryId
,
});
});
/// A method that pulls an SkSL shader from the device and writes it to a file.
///
/// The name of the file returned as a result.
typedef
GetSkSLMethod
=
Future
<
String
>
Function
();
Future
<
io
.
WebSocket
>
_defaultOpenChannel
(
String
url
,
{
Future
<
io
.
WebSocket
>
_defaultOpenChannel
(
String
url
,
{
io
.
CompressionOptions
compression
=
io
.
CompressionOptions
.
compressionDefault
io
.
CompressionOptions
compression
=
io
.
CompressionOptions
.
compressionDefault
})
async
{
})
async
{
...
@@ -139,6 +145,7 @@ typedef VMServiceConnector = Future<vm_service.VmService> Function(Uri httpUri,
...
@@ -139,6 +145,7 @@ typedef VMServiceConnector = Future<vm_service.VmService> Function(Uri httpUri,
Restart
restart
,
Restart
restart
,
CompileExpression
compileExpression
,
CompileExpression
compileExpression
,
ReloadMethod
reloadMethod
,
ReloadMethod
reloadMethod
,
GetSkSLMethod
getSkSLMethod
,
io
.
CompressionOptions
compression
,
io
.
CompressionOptions
compression
,
Device
device
,
Device
device
,
});
});
...
@@ -164,6 +171,7 @@ vm_service.VmService setUpVmService(
...
@@ -164,6 +171,7 @@ vm_service.VmService setUpVmService(
CompileExpression
compileExpression
,
CompileExpression
compileExpression
,
Device
device
,
Device
device
,
ReloadMethod
reloadMethod
,
ReloadMethod
reloadMethod
,
GetSkSLMethod
skSLMethod
,
vm_service
.
VmService
vmService
vm_service
.
VmService
vmService
)
{
)
{
if
(
reloadSources
!=
null
)
{
if
(
reloadSources
!=
null
)
{
...
@@ -270,6 +278,18 @@ vm_service.VmService setUpVmService(
...
@@ -270,6 +278,18 @@ vm_service.VmService setUpVmService(
});
});
vmService
.
registerService
(
'flutterMemoryInfo'
,
'Flutter Tools'
);
vmService
.
registerService
(
'flutterMemoryInfo'
,
'Flutter Tools'
);
}
}
if
(
skSLMethod
!=
null
)
{
vmService
.
registerServiceCallback
(
'flutterGetSkSL'
,
(
Map
<
String
,
dynamic
>
params
)
async
{
final
String
filename
=
await
skSLMethod
();
return
<
String
,
dynamic
>{
'result'
:
<
String
,
Object
>{
'type'
:
'Success'
,
'filename'
:
filename
,
}
};
});
vmService
.
registerService
(
'flutterGetSkSL'
,
'Flutter Tools'
);
}
return
vmService
;
return
vmService
;
}
}
...
@@ -287,6 +307,7 @@ Future<vm_service.VmService> connectToVmService(
...
@@ -287,6 +307,7 @@ Future<vm_service.VmService> connectToVmService(
Restart
restart
,
Restart
restart
,
CompileExpression
compileExpression
,
CompileExpression
compileExpression
,
ReloadMethod
reloadMethod
,
ReloadMethod
reloadMethod
,
GetSkSLMethod
getSkSLMethod
,
io
.
CompressionOptions
compression
=
io
.
CompressionOptions
.
compressionDefault
,
io
.
CompressionOptions
compression
=
io
.
CompressionOptions
.
compressionDefault
,
Device
device
,
Device
device
,
})
async
{
})
async
{
...
@@ -298,6 +319,7 @@ Future<vm_service.VmService> connectToVmService(
...
@@ -298,6 +319,7 @@ Future<vm_service.VmService> connectToVmService(
compression:
compression
,
compression:
compression
,
device:
device
,
device:
device
,
reloadMethod:
reloadMethod
,
reloadMethod:
reloadMethod
,
getSkSLMethod:
getSkSLMethod
,
);
);
}
}
...
@@ -307,6 +329,7 @@ Future<vm_service.VmService> _connect(
...
@@ -307,6 +329,7 @@ Future<vm_service.VmService> _connect(
Restart
restart
,
Restart
restart
,
CompileExpression
compileExpression
,
CompileExpression
compileExpression
,
ReloadMethod
reloadMethod
,
ReloadMethod
reloadMethod
,
GetSkSLMethod
getSkSLMethod
,
io
.
CompressionOptions
compression
=
io
.
CompressionOptions
.
compressionDefault
,
io
.
CompressionOptions
compression
=
io
.
CompressionOptions
.
compressionDefault
,
Device
device
,
Device
device
,
})
async
{
})
async
{
...
@@ -333,6 +356,7 @@ Future<vm_service.VmService> _connect(
...
@@ -333,6 +356,7 @@ Future<vm_service.VmService> _connect(
compileExpression
,
compileExpression
,
device
,
device
,
reloadMethod
,
reloadMethod
,
getSkSLMethod
,
delegateService
,
delegateService
,
);
);
_httpAddressExpando
[
service
]
=
httpUri
;
_httpAddressExpando
[
service
]
=
httpUri
;
...
...
packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart
View file @
60033828
...
@@ -678,6 +678,7 @@ VMServiceConnector getFakeVmServiceFactory({
...
@@ -678,6 +678,7 @@ VMServiceConnector getFakeVmServiceFactory({
Restart
restart
,
Restart
restart
,
CompileExpression
compileExpression
,
CompileExpression
compileExpression
,
ReloadMethod
reloadMethod
,
ReloadMethod
reloadMethod
,
GetSkSLMethod
getSkSLMethod
,
CompressionOptions
compression
,
CompressionOptions
compression
,
Device
device
,
Device
device
,
})
async
{
})
async
{
...
...
packages/flutter_tools/test/general.shard/cold_test.dart
View file @
60033828
...
@@ -184,6 +184,7 @@ class TestFlutterDevice extends FlutterDevice {
...
@@ -184,6 +184,7 @@ class TestFlutterDevice extends FlutterDevice {
Restart
restart
,
Restart
restart
,
CompileExpression
compileExpression
,
CompileExpression
compileExpression
,
ReloadMethod
reloadMethod
,
ReloadMethod
reloadMethod
,
GetSkSLMethod
getSkSLMethod
,
})
async
{
})
async
{
throw
exception
;
throw
exception
;
}
}
...
...
packages/flutter_tools/test/general.shard/hot_test.dart
View file @
60033828
...
@@ -541,6 +541,7 @@ class TestFlutterDevice extends FlutterDevice {
...
@@ -541,6 +541,7 @@ class TestFlutterDevice extends FlutterDevice {
Restart
restart
,
Restart
restart
,
CompileExpression
compileExpression
,
CompileExpression
compileExpression
,
ReloadMethod
reloadMethod
,
ReloadMethod
reloadMethod
,
GetSkSLMethod
getSkSLMethod
,
})
async
{
})
async
{
throw
exception
;
throw
exception
;
}
}
...
...
packages/flutter_tools/test/general.shard/resident_runner_test.dart
View file @
60033828
...
@@ -144,6 +144,7 @@ void main() {
...
@@ -144,6 +144,7 @@ void main() {
reloadSources:
anyNamed
(
'reloadSources'
),
reloadSources:
anyNamed
(
'reloadSources'
),
restart:
anyNamed
(
'restart'
),
restart:
anyNamed
(
'restart'
),
compileExpression:
anyNamed
(
'compileExpression'
),
compileExpression:
anyNamed
(
'compileExpression'
),
getSkSLMethod:
anyNamed
(
'getSkSLMethod'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
});
)).
thenAnswer
((
Invocation
invocation
)
async
{
});
when
(
mockFlutterDevice
.
setupDevFS
(
any
,
any
,
packagesFilePath:
anyNamed
(
'packagesFilePath'
)))
when
(
mockFlutterDevice
.
setupDevFS
(
any
,
any
,
packagesFilePath:
anyNamed
(
'packagesFilePath'
)))
.
thenAnswer
((
Invocation
invocation
)
async
{
.
thenAnswer
((
Invocation
invocation
)
async
{
...
@@ -1191,6 +1192,7 @@ void main() {
...
@@ -1191,6 +1192,7 @@ void main() {
Restart
restart
,
Restart
restart
,
CompileExpression
compileExpression
,
CompileExpression
compileExpression
,
ReloadMethod
reloadMethod
,
ReloadMethod
reloadMethod
,
GetSkSLMethod
getSkSLMethod
,
io
.
CompressionOptions
compression
,
io
.
CompressionOptions
compression
,
Device
device
,
Device
device
,
})
async
=>
mockVMService
,
})
async
=>
mockVMService
,
...
...
packages/flutter_tools/test/general.shard/vmservice_test.dart
View file @
60033828
...
@@ -103,6 +103,7 @@ void main() {
...
@@ -103,6 +103,7 @@ void main() {
null
,
null
,
null
,
null
,
null
,
null
,
null
,
mockVMService
,
mockVMService
,
);
);
...
@@ -121,6 +122,7 @@ void main() {
...
@@ -121,6 +122,7 @@ void main() {
null
,
null
,
null
,
null
,
reloadMethod
,
reloadMethod
,
null
,
mockVMService
,
mockVMService
,
);
);
...
@@ -139,6 +141,7 @@ void main() {
...
@@ -139,6 +141,7 @@ void main() {
null
,
null
,
mockDevice
,
mockDevice
,
null
,
null
,
null
,
mockVMService
,
mockVMService
,
);
);
...
@@ -147,6 +150,23 @@ void main() {
...
@@ -147,6 +150,23 @@ void main() {
Logger:
()
=>
BufferLogger
.
test
()
Logger:
()
=>
BufferLogger
.
test
()
});
});
testUsingContext
(
'VmService registers flutterGetSkSL service'
,
()
async
{
final
MockVMService
mockVMService
=
MockVMService
();
setUpVmService
(
null
,
null
,
null
,
null
,
null
,
()
async
=>
'hello'
,
mockVMService
,
);
verify
(
mockVMService
.
registerService
(
'flutterGetSkSL'
,
'Flutter Tools'
)).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
Logger:
()
=>
BufferLogger
.
test
()
});
testUsingContext
(
'VMService returns correct FlutterVersion'
,
()
async
{
testUsingContext
(
'VMService returns correct FlutterVersion'
,
()
async
{
final
MockVMService
mockVMService
=
MockVMService
();
final
MockVMService
mockVMService
=
MockVMService
();
setUpVmService
(
setUpVmService
(
...
@@ -155,6 +175,7 @@ void main() {
...
@@ -155,6 +175,7 @@ void main() {
null
,
null
,
null
,
null
,
null
,
null
,
null
,
mockVMService
,
mockVMService
,
);
);
...
...
packages/flutter_tools/test/integration.shard/vmservice_integration_test.dart
View file @
60033828
...
@@ -82,6 +82,12 @@ void main() {
...
@@ -82,6 +82,12 @@ void main() {
expect
(
response
,
throwsA
(
const
TypeMatcher
<
RPCError
>()));
expect
(
response
,
throwsA
(
const
TypeMatcher
<
RPCError
>()));
});
});
test
(
'flutterGetSkSL can be called'
,
()
async
{
final
Response
response
=
await
vmService
.
callMethod
(
's0.flutterGetSkSL'
);
expect
(
response
.
type
,
'Success'
);
});
// TODO(devoncarew): These tests fail on cirrus-ci windows.
// TODO(devoncarew): These tests fail on cirrus-ci windows.
},
skip:
Platform
.
isWindows
);
},
skip:
Platform
.
isWindows
);
}
}
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