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
6be4d1c8
Unverified
Commit
6be4d1c8
authored
Jan 24, 2021
by
Zachary Anderson
Committed by
GitHub
Jan 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Handle more cases where the tool receives RPCError 112 (#74574)" (#74601)
This reverts commit
c87f15fe
.
parent
c87f15fe
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
39 additions
and
225 deletions
+39
-225
screenshot.dart
packages/flutter_tools/lib/src/commands/screenshot.dart
+8
-26
devfs.dart
packages/flutter_tools/lib/src/devfs.dart
+0
-7
tracing.dart
packages/flutter_tools/lib/src/tracing.dart
+3
-8
vmservice.dart
packages/flutter_tools/lib/src/vmservice.dart
+22
-36
devfs_test.dart
packages/flutter_tools/test/general.shard/devfs_test.dart
+0
-81
tracing_test.dart
packages/flutter_tools/test/general.shard/tracing_test.dart
+0
-23
vmservice_test.dart
...ages/flutter_tools/test/general.shard/vmservice_test.dart
+6
-44
No files found.
packages/flutter_tools/lib/src/commands/screenshot.dart
View file @
6be4d1c8
...
...
@@ -97,21 +97,19 @@ class ScreenshotCommand extends FlutterCommand {
outputFile
=
globals
.
fs
.
file
(
stringArg
(
_kOut
));
}
bool
success
=
true
;
switch
(
stringArg
(
_kType
))
{
case
_kDeviceType:
await
runScreenshot
(
outputFile
);
break
;
return
FlutterCommandResult
.
success
()
;
case
_kSkiaType:
success
=
await
runSkia
(
outputFile
);
break
;
await
runSkia
(
outputFile
);
return
FlutterCommandResult
.
success
()
;
case
_kRasterizerType:
success
=
await
runRasterizer
(
outputFile
);
break
;
await
runRasterizer
(
outputFile
);
return
FlutterCommandResult
.
success
()
;
}
return
success
?
FlutterCommandResult
.
success
()
:
FlutterCommandResult
.
fail
();
return
FlutterCommandResult
.
success
();
}
Future
<
void
>
runScreenshot
(
File
outputFile
)
async
{
...
...
@@ -128,17 +126,10 @@ class ScreenshotCommand extends FlutterCommand {
_showOutputFileInfo
(
outputFile
);
}
Future
<
bool
>
runSkia
(
File
outputFile
)
async
{
Future
<
void
>
runSkia
(
File
outputFile
)
async
{
final
Uri
observatoryUri
=
Uri
.
parse
(
stringArg
(
_kObservatoryUri
));
final
vm_service
.
VmService
vmService
=
await
connectToVmService
(
observatoryUri
);
final
vm_service
.
Response
skp
=
await
vmService
.
screenshotSkp
();
if
(
skp
==
null
)
{
globals
.
printError
(
'The Skia picture request failed, probably because the device was '
'disconnected'
,
);
return
false
;
}
outputFile
??=
globals
.
fsUtils
.
getUniqueFile
(
globals
.
fs
.
currentDirectory
,
'flutter'
,
...
...
@@ -149,20 +140,12 @@ class ScreenshotCommand extends FlutterCommand {
await
sink
.
close
();
_showOutputFileInfo
(
outputFile
);
_ensureOutputIsNotJsonRpcError
(
outputFile
);
return
true
;
}
Future
<
bool
>
runRasterizer
(
File
outputFile
)
async
{
Future
<
void
>
runRasterizer
(
File
outputFile
)
async
{
final
Uri
observatoryUri
=
Uri
.
parse
(
stringArg
(
_kObservatoryUri
));
final
vm_service
.
VmService
vmService
=
await
connectToVmService
(
observatoryUri
);
final
vm_service
.
Response
response
=
await
vmService
.
screenshot
();
if
(
response
==
null
)
{
globals
.
printError
(
'The screenshot request failed, probably because the device was '
'disconnected'
,
);
return
false
;
}
outputFile
??=
globals
.
fsUtils
.
getUniqueFile
(
globals
.
fs
.
currentDirectory
,
'flutter'
,
...
...
@@ -173,7 +156,6 @@ class ScreenshotCommand extends FlutterCommand {
await
sink
.
close
();
_showOutputFileInfo
(
outputFile
);
_ensureOutputIsNotJsonRpcError
(
outputFile
);
return
true
;
}
void
_ensureOutputIsNotJsonRpcError
(
File
outputFile
)
{
...
...
packages/flutter_tools/lib/src/devfs.dart
View file @
6be4d1c8
...
...
@@ -419,15 +419,8 @@ class DevFS {
final
vm_service
.
Response
response
=
await
_vmService
.
createDevFS
(
fsName
);
_baseUri
=
Uri
.
parse
(
response
.
json
[
'uri'
]
as
String
);
}
on
vm_service
.
RPCError
catch
(
rpcException
)
{
if
(
rpcException
.
code
==
RPCErrorCodes
.
kServiceDisappeared
)
{
// This can happen if the device has been disconnected, so translate to
// a DevFSException, which the caller will handle.
throw
DevFSException
(
'Service disconnected'
,
rpcException
);
}
// 1001 is kFileSystemAlreadyExists in //dart/runtime/vm/json_stream.h
if
(
rpcException
.
code
!=
1001
)
{
// Other RPCErrors are unexpected. Rethrow so it will hit crash
// logging.
rethrow
;
}
_logger
.
printTrace
(
'DevFS: Creating failed. Destroying and trying again'
);
...
...
packages/flutter_tools/lib/src/tracing.dart
View file @
6be4d1c8
...
...
@@ -32,7 +32,7 @@ class Tracing {
final
Logger
_logger
;
Future
<
void
>
startTracing
()
async
{
await
vmService
.
setTimelineFlags
(<
String
>[
'Compiler'
,
'Dart'
,
'Embedder'
,
'GC'
]);
await
vmService
.
set
VM
TimelineFlags
(<
String
>[
'Compiler'
,
'Dart'
,
'Embedder'
,
'GC'
]);
await
vmService
.
clearVMTimeline
();
}
...
...
@@ -78,13 +78,8 @@ class Tracing {
}
status
.
stop
();
}
final
vm_service
.
Response
timeline
=
await
vmService
.
getTimeline
();
await
vmService
.
setTimelineFlags
(<
String
>[]);
if
(
timeline
==
null
)
{
throwToolExit
(
'The device disconnected before the timeline could be retrieved.'
,
);
}
final
vm_service
.
Timeline
timeline
=
await
vmService
.
getVMTimeline
();
await
vmService
.
setVMTimelineFlags
(<
String
>[]);
return
timeline
.
json
;
}
}
...
...
packages/flutter_tools/lib/src/vmservice.dart
View file @
6be4d1c8
...
...
@@ -728,12 +728,23 @@ extension FlutterVmService on vm_service.VmService {
return
null
;
}
Future
<
vm_service
.
Response
>
_checkedCallServiceExtension
(
/// Invoke a flutter extension method, if the flutter extension is not
/// available, returns null.
Future
<
Map
<
String
,
dynamic
>>
invokeFlutterExtensionRpcRaw
(
String
method
,
{
@required
String
isolateId
,
Map
<
String
,
dynamic
>
args
,
})
async
{
try
{
return
await
callServiceExtension
(
method
,
args:
args
);
final
vm_service
.
Response
response
=
await
callServiceExtension
(
method
,
args:
<
String
,
Object
>{
'isolateId'
:
isolateId
,
...?
args
,
},
);
return
response
.
json
;
}
on
vm_service
.
RPCError
catch
(
err
)
{
// If an application is not using the framework or the VM service
// disappears while handling a request, return null.
...
...
@@ -745,23 +756,6 @@ extension FlutterVmService on vm_service.VmService {
}
}
/// Invoke a flutter extension method, if the flutter extension is not
/// available, returns null.
Future
<
Map
<
String
,
dynamic
>>
invokeFlutterExtensionRpcRaw
(
String
method
,
{
@required
String
isolateId
,
Map
<
String
,
dynamic
>
args
,
})
async
{
final
vm_service
.
Response
response
=
await
_checkedCallServiceExtension
(
method
,
args:
<
String
,
Object
>{
'isolateId'
:
isolateId
,
...?
args
,
},
);
return
response
.
json
;
}
/// List all [FlutterView]s attached to the current VM.
///
/// If this returns an empty list, it will poll forever unless [returnEarly]
...
...
@@ -805,34 +799,26 @@ extension FlutterVmService on vm_service.VmService {
/// Create a new development file system on the device.
Future
<
vm_service
.
Response
>
createDevFS
(
String
fsName
)
{
// Call the unchecked version of `callServiceExtension` because the caller
// has custom handling of certain RPCErrors.
return
callServiceExtension
(
'_createDevFS'
,
args:
<
String
,
dynamic
>{
'fsName'
:
fsName
},
);
return
callServiceExtension
(
'_createDevFS'
,
args:
<
String
,
dynamic
>{
'fsName'
:
fsName
});
}
/// Delete an existing file system.
Future
<
void
>
deleteDevFS
(
String
fsName
)
async
{
await
_checkedCallServiceExtension
(
'_deleteDevFS'
,
args:
<
String
,
dynamic
>{
'fsName'
:
fsName
},
);
Future
<
vm_service
.
Response
>
deleteDevFS
(
String
fsName
)
{
return
callServiceExtension
(
'_deleteDevFS'
,
args:
<
String
,
dynamic
>{
'fsName'
:
fsName
});
}
Future
<
vm_service
.
Response
>
screenshot
()
{
return
_checkedC
allServiceExtension
(
kScreenshotMethod
);
return
c
allServiceExtension
(
kScreenshotMethod
);
}
Future
<
vm_service
.
Response
>
screenshotSkp
()
{
return
_checkedC
allServiceExtension
(
kScreenshotSkpMethod
);
return
c
allServiceExtension
(
kScreenshotSkpMethod
);
}
/// Set the VM timeline flags.
Future
<
v
oid
>
setTimelineFlags
(
List
<
String
>
recordedStreams
)
async
{
Future
<
v
m_service
.
Response
>
setVMTimelineFlags
(
List
<
String
>
recordedStreams
)
{
assert
(
recordedStreams
!=
null
);
await
_checkedC
allServiceExtension
(
return
c
allServiceExtension
(
'setVMTimelineFlags'
,
args:
<
String
,
dynamic
>{
'recordedStreams'
:
recordedStreams
,
...
...
@@ -840,8 +826,8 @@ extension FlutterVmService on vm_service.VmService {
);
}
Future
<
vm_service
.
Response
>
getTimeline
()
{
return
_checkedC
allServiceExtension
(
'getVMTimeline'
);
Future
<
vm_service
.
Response
>
get
VM
Timeline
()
{
return
c
allServiceExtension
(
'getVMTimeline'
);
}
}
...
...
packages/flutter_tools/test/general.shard/devfs_test.dart
View file @
6be4d1c8
...
...
@@ -31,20 +31,6 @@ final FakeVmServiceRequest createDevFSRequest = FakeVmServiceRequest(
}
);
const
FakeVmServiceRequest
failingCreateDevFSRequest
=
FakeVmServiceRequest
(
method:
'_createDevFS'
,
args:
<
String
,
Object
>{
'fsName'
:
'test'
,
},
errorCode:
RPCErrorCodes
.
kServiceDisappeared
,
);
const
FakeVmServiceRequest
failingDeleteDevFSRequest
=
FakeVmServiceRequest
(
method:
'_deleteDevFS'
,
args:
<
String
,
dynamic
>{
'fsName'
:
'test'
},
errorCode:
RPCErrorCodes
.
kServiceDisappeared
,
);
void
main
(
)
{
testWithoutContext
(
'DevFSByteContent'
,
()
{
final
DevFSByteContent
content
=
DevFSByteContent
(<
int
>[
4
,
5
,
6
]);
...
...
@@ -107,73 +93,6 @@ void main() {
expect
(
content
.
isModified
,
isFalse
);
});
testWithoutContext
(
'DevFS create throws a DevFSException when vmservice disconnects unexpectedly'
,
()
async
{
final
HttpClient
httpClient
=
MockHttpClient
();
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
OperatingSystemUtils
osUtils
=
MockOperatingSystemUtils
();
final
FakeVmServiceHost
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
failingCreateDevFSRequest
],
);
setHttpAddress
(
Uri
.
parse
(
'http://localhost'
),
fakeVmServiceHost
.
vmService
);
final
MockHttpClientRequest
httpRequest
=
MockHttpClientRequest
();
when
(
httpRequest
.
headers
).
thenReturn
(
MockHttpHeaders
());
when
(
httpClient
.
putUrl
(
any
)).
thenAnswer
((
Invocation
invocation
)
{
return
Future
<
HttpClientRequest
>.
value
(
httpRequest
);
});
final
MockHttpClientResponse
httpClientResponse
=
MockHttpClientResponse
();
when
(
httpRequest
.
close
()).
thenAnswer
((
Invocation
invocation
)
{
return
Future
<
HttpClientResponse
>.
value
(
httpClientResponse
);
});
final
DevFS
devFS
=
DevFS
(
fakeVmServiceHost
.
vmService
,
'test'
,
fileSystem
.
currentDirectory
,
osUtils:
osUtils
,
fileSystem:
fileSystem
,
logger:
BufferLogger
.
test
(),
httpClient:
httpClient
,
);
expect
(()
async
=>
await
devFS
.
create
(),
throwsA
(
isA
<
DevFSException
>()));
});
testWithoutContext
(
'DevFS destroy is resiliant to vmservice disconnection'
,
()
async
{
final
HttpClient
httpClient
=
MockHttpClient
();
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
OperatingSystemUtils
osUtils
=
MockOperatingSystemUtils
();
final
FakeVmServiceHost
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
createDevFSRequest
,
failingDeleteDevFSRequest
,
],
);
setHttpAddress
(
Uri
.
parse
(
'http://localhost'
),
fakeVmServiceHost
.
vmService
);
final
MockHttpClientRequest
httpRequest
=
MockHttpClientRequest
();
when
(
httpRequest
.
headers
).
thenReturn
(
MockHttpHeaders
());
when
(
httpClient
.
putUrl
(
any
)).
thenAnswer
((
Invocation
invocation
)
{
return
Future
<
HttpClientRequest
>.
value
(
httpRequest
);
});
final
MockHttpClientResponse
httpClientResponse
=
MockHttpClientResponse
();
when
(
httpRequest
.
close
()).
thenAnswer
((
Invocation
invocation
)
{
return
Future
<
HttpClientResponse
>.
value
(
httpClientResponse
);
});
final
DevFS
devFS
=
DevFS
(
fakeVmServiceHost
.
vmService
,
'test'
,
fileSystem
.
currentDirectory
,
osUtils:
osUtils
,
fileSystem:
fileSystem
,
logger:
BufferLogger
.
test
(),
httpClient:
httpClient
,
);
expect
(
await
devFS
.
create
(),
isNotNull
);
await
devFS
.
destroy
();
// Testing that this does not throw.
});
testWithoutContext
(
'DevFS retries uploads when connection reset by peer'
,
()
async
{
final
HttpClient
httpClient
=
MockHttpClient
();
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
...
...
packages/flutter_tools/test/general.shard/tracing_test.dart
View file @
6be4d1c8
...
...
@@ -130,29 +130,6 @@ void main() {
});
});
testWithoutContext
(
'throws tool exit if the vmservice disconnects'
,
()
async
{
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
FakeVmServiceHost
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
FakeVmServiceRequest
>[
...
vmServiceSetup
,
const
FakeVmServiceRequest
(
method:
'getVMTimeline'
,
errorCode:
RPCErrorCodes
.
kServiceDisappeared
,
),
const
FakeVmServiceRequest
(
method:
'setVMTimelineFlags'
,
args:
<
String
,
Object
>{
'recordedStreams'
:
<
Object
>[],
},
),
]);
await
expectLater
(()
async
=>
await
downloadStartupTrace
(
fakeVmServiceHost
.
vmService
,
output:
fileSystem
.
currentDirectory
,
logger:
logger
,
),
throwsToolExit
(
message:
'The device disconnected before the timeline could be retrieved.'
));
});
testWithoutContext
(
'throws tool exit if timeline is missing the engine start event'
,
()
async
{
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
...
...
packages/flutter_tools/test/general.shard/vmservice_test.dart
View file @
6be4d1c8
...
...
@@ -315,58 +315,20 @@ void main() {
testWithoutContext
(
'Framework service extension invocations return null if service disappears '
,
()
async
{
final
FakeVmServiceHost
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
const
FakeVmServiceRequest
(
method:
kGetSkSLsMethod
,
args:
<
String
,
Object
>{
'viewId'
:
'1234'
,
},
errorCode:
RPCErrorCodes
.
kServiceDisappeared
,
),
const
FakeVmServiceRequest
(
method:
kListViewsMethod
,
errorCode:
RPCErrorCodes
.
kServiceDisappeared
,
),
const
FakeVmServiceRequest
(
method:
kScreenshotMethod
,
errorCode:
RPCErrorCodes
.
kServiceDisappeared
,
),
const
FakeVmServiceRequest
(
method:
kScreenshotSkpMethod
,
errorCode:
RPCErrorCodes
.
kServiceDisappeared
,
),
const
FakeVmServiceRequest
(
method:
'setVMTimelineFlags'
,
args:
<
String
,
dynamic
>{
'recordedStreams'
:
<
String
>[
'test'
],
},
errorCode:
RPCErrorCodes
.
kServiceDisappeared
,
),
const
FakeVmServiceRequest
(
method:
'getVMTimeline'
,
errorCode:
RPCErrorCodes
.
kServiceDisappeared
,
),
const
FakeVmServiceRequest
(
method:
kGetSkSLsMethod
,
args:
<
String
,
Object
>{
'viewId'
:
'1234'
,
},
errorCode:
RPCErrorCodes
.
kServiceDisappeared
),
const
FakeVmServiceRequest
(
method:
kListViewsMethod
,
errorCode:
RPCErrorCodes
.
kServiceDisappeared
),
]
);
final
Map
<
String
,
Object
>
skSLs
=
await
fakeVmServiceHost
.
vmService
.
getSkSLs
(
viewId:
'1234'
,
);
expect
(
skSLs
,
isN
ull
);
expect
(
skSLs
,
n
ull
);
final
List
<
FlutterView
>
views
=
await
fakeVmServiceHost
.
vmService
.
getFlutterViews
();
expect
(
views
,
isNull
);
final
vm_service
.
Response
screenshot
=
await
fakeVmServiceHost
.
vmService
.
screenshot
();
expect
(
screenshot
,
isNull
);
final
vm_service
.
Response
screenshotSkp
=
await
fakeVmServiceHost
.
vmService
.
screenshotSkp
();
expect
(
screenshotSkp
,
isNull
);
// Checking that this doesn't throw.
await
fakeVmServiceHost
.
vmService
.
setTimelineFlags
(<
String
>[
'test'
]);
final
vm_service
.
Response
timeline
=
await
fakeVmServiceHost
.
vmService
.
getTimeline
();
expect
(
timeline
,
isNull
);
expect
(
views
,
null
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
});
...
...
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