网络关闭的预加载功能
Posted
技术标签:
【中文标题】网络关闭的预加载功能【英文标题】:preload function with network off 【发布时间】:2017-08-09 09:52:19 【问题描述】:如果网络处于关闭状态(例如无法访问 youtube 页面),并且在平台上电时使用--preload
参数启动钴,则即使在切换时也无法加载和显示 youtube ui从预加载状态到启动状态,url无法重新加载,无法显示UI,那么对于这种情况,cobalt如何处理呢?
//Even the network is on, it can not reload the YT url from SbSystemRaisePlatformError, tsa03s02-in-f142.1e100.net is the hostname of www.youtube.com
64 bytes from tsa03s02-in-f142.1e100.net (172.217.27.142): icmp_req=51 ttl=52 time=49.1 ms
64 bytes from tsa03s02-in-f142.1e100.net (172.217.27.142): icmp_req=52 ttl=52 time=48.3 ms
64 bytes from tsa03s02-in-f142.1e100.net (172.217.27.142): icmp_req=53 ttl=52 time=66.7 ms
[cobalt]>[11604:2581014753:INFO:h5vcc_url_handler.cc(119)] try to reload url, url= https://www.youtube.com/tv?additionalDataUrl=http://localhost:56789/apps/YouTube/dial_data
[cobalt]>[11604:2581014916:INFO:system_raise_platform_error.cc(49)] SbSystemRaisePlatformError: Connection error.
[cobalt]>[0810/114518:WARNING:system_window.cc(200)] Failed to notify user of error: 0
[cobalt]>[12263:2581046785:WARNING:thread_set_name.cc(36)] Thread name "SplashScreenWebModule" was truncated to "SplashScreenWeb"
64 bytes from tsa03s02-in-f14.1e100.net (172.217.27.142): icmp_req=54 ttl=52 time=48.6 ms
[cobalt]>[0810/114518:INFO:page_visibility_state.cc(70)] PageVisibilityState: app_state=kApplicationStateStarted (2)
[cobalt]>[12267:2581204654:WARNING:thread_set_name.cc(36)] Thread name "Synchronous Load" was truncated to "Synchronous Loa"
[cobalt]>[11604:2581247952:INFO:window_get_size.cc(36)] SbWindowGetSizewidth: 1920, height: 1080, ratio: 1
[cobalt]>[0810/114518:INFO:fetcher_factory.cc(94)] Fetching: h5vcc-embedded://splash_screen.html
[cobalt]>[0810/114518:INFO:fetcher_factory.cc(94)] Fetching: h5vcc-embedded://splash_screen.css
[cobalt]>[0810/114518:INFO:fetcher_factory.cc(94)] Fetching: h5vcc-embedded://you_tube_logo.png
[cobalt]>[0810/114518:INFO:fetcher_factory.cc(94)] Fetching: h5vcc-embedded://splash_screen.js
[cobalt]>[0810/114518:INFO:page_visibility_state.cc(70)] PageVisibilityState: app_state=kApplicationStateStarted (2)
[cobalt]>[12272:2581440597:WARNING:thread_set_name.cc(36)] Thread name "Synchronous Load" was truncated to "Synchronous Loa"
[cobalt]>[0810/114518:INFO:fetcher_factory.cc(94)] Fetching: https://www.youtube.com/tv?additionalDataUrl=http://loc[...]
[cobalt]>[0810/114518:ERROR:host_resolver_proc.cc(155)] [AAAAA]host= www.youtube.com
[cobalt]>[0810/114518:ERROR:browser_module.cc(702)] NetFetcher error on : net::ERR_NAME_RESOLUTION_FAILED, response code -1
[cobalt]>[0810/114518:WARNING:h5vcc_url_handler.cc(30)] url=//network-failure?retry-url=https://www.youtube.com/tv?additionalDataUrl=http://localhost:56789/apps/YouTube/dial_data
[cobalt]>[0810/114518:WARNING:h5vcc_url_handler.cc(92)] HandleNetworkFailure:
64 bytes from tsa03s02-in-f14.1e100.net (172.217.27.142): icmp_req=55 ttl=52 time=48.6 ms
64 bytes from tsa03s02-in-f142.1e100.net (172.217.27.142): icmp_req=56 ttl=52 time=49.5 ms
64 bytes from tsa03s02-in-f14.1e100.net (172.217.27.142): icmp_req=57 ttl=52 time=67.3 ms
[cobalt]>[11604:2584493042:INFO:h5vcc_url_handler.cc(119)] try to reload url, url= https://www.youtube.com/tv?additionalDataUrl=http://localhost:56789/apps/YouTube/dial_data
【问题讨论】:
【参考方案1】:在常规的非预加载模式下,如果你在没有网络的情况下启动 Cobalt,它会尝试加载 URL,失败,然后调用 SbSystemRaisePlatformError,这通常会显示某种错误对话框,然后可以使用指标回调以重试。
在预加载模式下,情况并没有什么不同。从预加载到启动就像让应用可见,并不表示网络状态发生变化。
现在,如果实现在预加载模式下遇到平台错误,它可以等到转换开始,然后触发重试指示器。如果需要,这将取决于平台。
还有可以发送的网络状态改变事件(见starboard/event.h),但我不确定它们是否会导致Cobalt自动重试。
【讨论】:
嗨,大卫,我按照你的建议试过了,当它加载 youtube 失败时,然后尝试在 SbSystemRaisePlatformError 中重新加载它,但即使网络在后者,它仍然得到 ERR_NAME_RESOLUTION_FAILED,并进入SbSystemRaisePlatformError,它无法在网络开启的情况下重新加载 YT。 我把log msg加到question里了,请帮忙参考一下。 它似乎 SystemHostResolverProc 仍然失败,即使网络稍后打开。 嗨,大卫,我找到了这个问题的根本原因,当它重试重新加载 YT 页面时,它在 SystemHostResolverProc host_resolver_proc.cc 中设置了 ADDRESS_FRILY_UNSPECIFIED,如果我设置了这会使 sbsocketResolve 失败过滤器默认为kSbSocketResolveFilterIpv4,则效果很好。 如果您添加功能请求,我会尝试在 Cobalt 11 中将其转为修复...【参考方案2】:在SystemHostResolverProc
的SystemHostResolverProc
中设置过滤器默认为kSbSocketResolveFilterIpv4
host_resolver_proc.cc
,从网络关闭状态切换到网络状态时不会得到ERR_NAME_RESOLUTION_FAILED
,并且可以很好地重新加载YT页面。
【讨论】:
但是还有一个问题,当本地网络开启时,无法访问YT,即使稍后可以访问YT,也会一直报net::ERR_FAILED错误,并且无法重新加载YT以上是关于网络关闭的预加载功能的主要内容,如果未能解决你的问题,请参考以下文章